本文整理了Java中java.time.temporal.Temporal.get()
方法的一些代码示例,展示了Temporal.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Temporal.get()
方法的具体详情如下:
包路径:java.time.temporal.Temporal
类名称:Temporal
方法名:get
暂无
代码示例来源:origin: neo4j/neo4j
@Override
public final int get( TemporalField field )
{
int accessor;
try
{
accessor = temporal().get( field );
}
catch ( UnsupportedTemporalTypeException e )
{
throw new UnsupportedTemporalUnitException( e.getMessage(), e );
}
return accessor;
}
代码示例来源:origin: neo4j/neo4j
int fromNanos = from.isSupported( NANO_OF_SECOND ) ? from.get( NANO_OF_SECOND ) : 0;
int toNanos = to.isSupported( NANO_OF_SECOND ) ? to.get( NANO_OF_SECOND ) : 0;
nanos = toNanos - fromNanos;
&& from.isSupported( SECOND_OF_MINUTE )
&& to.isSupported( SECOND_OF_MINUTE )
&& from.get( SECOND_OF_MINUTE ) != to.get( SECOND_OF_MINUTE );
代码示例来源:origin: neo4j/neo4j
@SuppressWarnings( "unchecked" )
@Override
public <R extends Temporal> R adjustInto( R temporal, long newValue )
{
int newVal = range.checkValidIntValue( newValue, this );
int oldYear = temporal.get( ChronoField.YEAR );
return (R) temporal.with( ChronoField.YEAR, (oldYear / years) * years + newVal )
.with( TemporalAdjusters.firstDayOfYear() );
}
代码示例来源:origin: debezium/debezium
/**
* A utility method that adjusts <a href="https://dev.mysql.com/doc/refman/5.7/en/two-digit-years.html">ambiguous</a> 2-digit
* year values of DATETIME, DATE, and TIMESTAMP types using these MySQL-specific rules:
* <ul>
* <li>Year values in the range 00-69 are converted to 2000-2069.</li>
* <li>Year values in the range 70-99 are converted to 1970-1999.</li>
* </ul>
*
* @param temporal the temporal instance to adjust; may not be null
* @return the possibly adjusted temporal instance; never null
*/
protected static Temporal adjustTemporal(Temporal temporal) {
if (temporal.isSupported(ChronoField.YEAR)) {
int year = temporal.get(ChronoField.YEAR);
if (0 <= year && year <= 69) {
temporal = temporal.plus(2000, ChronoUnit.YEARS);
} else if (70 <= year && year <= 99) {
temporal = temporal.plus(1900, ChronoUnit.YEARS);
}
}
return temporal;
}
代码示例来源:origin: neo4j/neo4j
AnyValue millis = Values.intValue( temporal.get( ChronoField.MILLI_OF_SECOND ) );
AnyValue micros = fields.get( "microsecond" );
AnyValue nanos = fields.get( "nanosecond" );
AnyValue micros = Values.intValue( temporal.get( ChronoField.MICRO_OF_SECOND ) );
AnyValue nanos = fields.get( "nanosecond" );
int newNanos = validNano( null, micros, nanos );
代码示例来源:origin: eclipse/smarthome
/**
* A check that we do not go ballistic with the year
*/
private static boolean checkMaxYear(Temporal temporal) {
return temporal.get(ChronoField.YEAR) >= 2200;
}
代码示例来源:origin: eclipse/smarthome
/**
* This is the # syntax. We must check that the given weekday is the nth one
* in the current month. So we take the day of the month and divide it by 7.
*
* @param temporal temporal to check
* @param nDayInMonth the nth day in the current month to check
* @return true if temporal matches nth day in month
*/
private static boolean isNthWeekDayInMonth(Temporal temporal, int nDayInMonth) {
final int day = temporal.get(ChronoField.DAY_OF_MONTH);
final int occurrences = 1 + (day - 1) / 7;
return nDayInMonth == occurrences;
}
代码示例来源:origin: eclipse/smarthome
/**
* Check for the nearest working day. E.g. 15W is the nearest working day around the 15th.
*
* @param temporal temporal to check
* @return true if temporal is nearest to working day
*/
static boolean isNearestWorkDay(Temporal temporal, int target) {
final int day = temporal.get(ChronoField.DAY_OF_MONTH);
final DayOfWeek type = DayOfWeek.of(temporal.get(ChronoField.DAY_OF_WEEK));
switch (type) {
case MONDAY:
return day == target // the actual day
|| day == target + 1 // target was on a Sunday
|| (day == target + 2 && day == 3); // target was Saturday 1
case TUESDAY:
case WEDNESDAY:
case THURSDAY:
return day == target;
case FRIDAY:
return day == target || day + 1 == target;
// not a work day
default:
case SATURDAY:
case SUNDAY:
return false;
}
}
代码示例来源:origin: eclipse/smarthome
/**
* @param temporal temporal to check
* @return true if temporal is the last week day in this month. I.e. the last Saturday
*/
private static boolean isLastOfThisWeekDayInMonth(Temporal temporal) {
final int day = temporal.get(ChronoField.DAY_OF_MONTH);
final int max = (int) ChronoField.DAY_OF_MONTH.rangeRefinedBy(temporal).getMaximum();
return day + 7 > max;
}
代码示例来源:origin: eclipse/smarthome
/**
* @param temporal temporal to check
* @return true if temporal is the last day in the month
*/
private static boolean isLastDayInMonth(Temporal temporal) {
final int day = temporal.get(ChronoField.DAY_OF_MONTH);
final int max = (int) ChronoField.DAY_OF_MONTH.rangeRefinedBy(temporal).getMaximum();
return day == max;
}
代码示例来源:origin: eclipse/smarthome
/**
* @param temporal temporal to check
* @return true if temporal is the last working day in the month
*/
private static boolean isLastWorkingDayInMonth(Temporal temporal) {
final int day = temporal.get(ChronoField.DAY_OF_MONTH);
final DayOfWeek type = DayOfWeek.of(temporal.get(ChronoField.DAY_OF_WEEK));
final int max = (int) ChronoField.DAY_OF_MONTH.rangeRefinedBy(temporal).getMaximum();
switch (type) {
case MONDAY:
case TUESDAY:
case WEDNESDAY:
case THURSDAY:
return day == max;
case FRIDAY:
return day + 2 >= max;
default:
case SATURDAY:
case SUNDAY:
return false;
}
}
代码示例来源:origin: eclipse/smarthome
if (m.matches()) {
final int day = parseInt(cronExpression, chronoField, m.group("day"), min, max, names);
final Checker c = temporal -> temporal.get(ChronoField.DAY_OF_WEEK) == day;
final int n = temporal.get(chronoField);
final int n = temporal.get(chronoField);
代码示例来源:origin: baratine/baratine
@Override
public void format(StringBuilder sb, Temporal cal)
{
int month = cal.get(ChronoField.MONTH_OF_YEAR);
sb.append((month) / 10);
sb.append((month) % 10);
}
}
代码示例来源:origin: baratine/baratine
@Override
public void format(StringBuilder sb, Temporal cal)
{
int minute = cal.get(ChronoField.MINUTE_OF_HOUR);
sb.append((minute / 10) % 6);
sb.append((minute) % 10);
}
}
代码示例来源:origin: baratine/baratine
@Override
public void format(StringBuilder sb, Temporal cal)
{
int second = cal.get(ChronoField.SECOND_OF_MINUTE);
sb.append((second / 10) % 6);
sb.append((second) % 10);
}
}
代码示例来源:origin: com.addthis/cronus
/**
* Returns true of the minute and hour components of a pattern are matching.
*/
private boolean minuteHourMatches(Temporal candidate) {
return minute.test(candidate.get(ChronoField.MINUTE_OF_HOUR)) &&
hour.test(candidate.get(ChronoField.HOUR_OF_DAY));
}
代码示例来源:origin: com.impossibl.pgjdbc-ng/pgjdbc-ng
@Override
public String format(Temporal temporal) {
if (temporal.get(ChronoField.ERA) != IsoEra.CE.getValue()) {
return FMT_ERA.format(temporal);
}
return FMT.format(temporal);
}
代码示例来源:origin: org.leapframework/leap-core
public static int minute(Object t) {
if(t instanceof Date) {
return Dates.toCalendar((Date)t).get(Calendar.MINUTE);
}
if(t instanceof Instant) {
return DateTimes.toLocalDateTime((Instant)t).getMinute();
}
if(t instanceof Temporal) {
return ((Temporal) t).get(ChronoField.MINUTE_OF_HOUR);
}
throw new IllegalStateException(t + " is not a valid or supported time");
}
代码示例来源:origin: org.neo4j/neo4j-values
@SuppressWarnings( "unchecked" )
@Override
public <R extends Temporal> R adjustInto( R temporal, long newValue )
{
int newVal = range.checkValidIntValue( newValue, this );
int oldYear = temporal.get( ChronoField.YEAR );
return (R) temporal.with( ChronoField.YEAR, (oldYear / years) * years + newVal )
.with( TemporalAdjusters.firstDayOfYear() );
}
代码示例来源:origin: org.omnifaces/omniutils
public static TemporalAdjuster nextOrSameDayOfMonth(int dayOfMonth) {
validateDayOfMonth(dayOfMonth);
TemporalAdjuster nextDayOfMonth = nextDayOfMonth(dayOfMonth);
return temporal -> {
int currentDayOfMonth = temporal.get(DAY_OF_MONTH);
if (currentDayOfMonth == dayOfMonth || (currentDayOfMonth < dayOfMonth && currentDayOfMonth == temporal.range(DAY_OF_MONTH).getMaximum())) {
return temporal;
}
return temporal.with(nextDayOfMonth);
};
}
内容来源于网络,如有侵权,请联系作者删除!