本文整理了Java中java.time.temporal.TemporalQueries.localDate()
方法的一些代码示例,展示了TemporalQueries.localDate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TemporalQueries.localDate()
方法的具体详情如下:
包路径:java.time.temporal.TemporalQueries
类名称:TemporalQueries
方法名:localDate
[英]A query for LocalDate returning null if not found.
This returns a TemporalQuery that can be used to query a temporal object for the local date. The query will return null if the temporal object cannot supply a local date.
The query implementation examines the ChronoField#EPOCH_DAYfield and uses it to create a LocalDate.
[中]如果找不到LocalDate,则返回null的查询。
这将返回一个临时查询,可用于查询本地日期的临时对象。如果时态对象不能提供本地日期,查询将返回null。
查询实现检查ChronoField#EPOCH_DAYfield并使用它创建LocalDate。
代码示例来源:origin: neo4j/neo4j
final LocalDate expectedDate = ((Temporal) expectedValue).query( TemporalQueries.localDate() );
final LocalTime expectedTime = ((Temporal) expectedValue).query( TemporalQueries.localTime() );
final ZoneId expectedZOneId= ((Temporal) expectedValue).query( TemporalQueries.zone() );
LocalDate actualDate = ((Temporal) actualValue).query( TemporalQueries.localDate() );
LocalTime actualTime = ((Temporal) actualValue).query( TemporalQueries.localTime() );
ZoneId actualZOneId= ((Temporal) actualValue).query( TemporalQueries.zone() );
代码示例来源:origin: org.threeten/threeten-extra
@SuppressWarnings("unchecked")
@Override
public
if (query == TemporalQueries.localDate()) {
return (R) isoDate;
}
return super.query(query);
}
代码示例来源:origin: com.nhl.link.rest/link-rest-base
private Optional
return Optional.ofNullable(parsed.query(TemporalQueries.localDate()));
}
代码示例来源:origin: agrestio/agrest
private Optional
return Optional.ofNullable(parsed.query(TemporalQueries.localDate()));
}
代码示例来源:origin: com.github.seratch/java-time-backport
/**
* Queries this date-time using the specified query.
*
* This queries this date-time using the specified query strategy object.
* The {@code TemporalQuery} object defines the logic to be used to
* obtain the result. Read the documentation of the query to understand
* what the result of this method will be.
*
* The result of this method is obtained by invoking the
* {@link TemporalQuery#queryFrom(TemporalAccessor)} method on the
* specified query passing {@code this} as the argument.
*
* @param
* @param query the query to invoke, not null
* @return the query result, null may be returned (defined by the query)
* @throws DateTimeException if unable to query (defined by the query)
* @throws ArithmeticException if numeric overflow occurs (defined by the query)
*/
@SuppressWarnings("unchecked")
@Override // override for Javadoc
public
if (query == TemporalQueries.localDate()) {
return (R) toLocalDate();
}
return super.query(query);
}
代码示例来源:origin: com.github.seratch/java-time-backport
/**
* Queries this date using the specified query.
*
* This queries this date using the specified query strategy object.
* The {@code TemporalQuery} object defines the logic to be used to
* obtain the result. Read the documentation of the query to understand
* what the result of this method will be.
*
* The result of this method is obtained by invoking the
* {@link TemporalQuery#queryFrom(TemporalAccessor)} method on the
* specified query passing {@code this} as the argument.
*
* @param
* @param query the query to invoke, not null
* @return the query result, null may be returned (defined by the query)
* @throws DateTimeException if unable to query (defined by the query)
* @throws ArithmeticException if numeric overflow occurs (defined by the query)
*/
@SuppressWarnings("unchecked")
@Override
public
if (query == TemporalQueries.localDate()) {
return (R) this;
}
return super.query(query);
}
代码示例来源:origin: com.github.seratch/java-time-backport
/**
* Obtains an instance of {@code LocalDate} from a temporal object.
*
* A {@code TemporalAccessor} represents some form of date and time information.
* This factory converts the arbitrary temporal object to an instance of {@code LocalDate}.
*
* The conversion uses the {@link TemporalQueries#localDate()} query, which relies
* on extracting the {@link ChronoField#EPOCH_DAY EPOCH_DAY} field.
*
* This method matches the signature of the functional interface {@link TemporalQuery}
* allowing it to be used as a query via method reference, {@code LocalDate::from}.
*
* @param temporal the temporal object to convert, not null
* @return the local date, not null
* @throws DateTimeException if unable to convert to a {@code LocalDate}
*/
public static LocalDate from(TemporalAccessor temporal) {
LocalDate date = temporal.query(TemporalQueries.localDate());
if (date == null) {
throw new DateTimeException("Unable to obtain LocalDate from TemporalAccessor: " +
temporal + ", type " + temporal.getClass().getName());
}
return date;
}
代码示例来源:origin: eXparity/hamcrest-date
@Override
protected boolean matchesSafely(final T actual, final Description mismatchDesc) {
if (!this.adapter.asTemporal(actual, zone).query(localDate()).isLeapYear()) {
mismatchDesc.appendText("the date " + this.formatter.describe(actual) + " is not a leap year");
return false;
} else {
return true;
}
}
代码示例来源:origin: com.github.seratch/java-time-backport
@SuppressWarnings("unchecked")
@Override
public
if (query == TemporalQueries.precision()) {
return (R) ChronoUnit.ERAS;
}
if (query == TemporalQueries.chronology() || query == TemporalQueries.zone() ||
query == TemporalQueries.zoneId() || query == TemporalQueries.offset() ||
query == TemporalQueries.localDate() || query == TemporalQueries.localTime()) {
return null;
}
return query.queryFrom(this);
}
代码示例来源:origin: com.github.seratch/java-time-backport
@SuppressWarnings("unchecked")
@Override
public
if (query == TemporalQueries.precision()) {
return (R) ChronoUnit.ERAS;
}
if (query == TemporalQueries.chronology() || query == TemporalQueries.zone() ||
query == TemporalQueries.zoneId() || query == TemporalQueries.offset() ||
query == TemporalQueries.localDate() || query == TemporalQueries.localTime()) {
return null;
}
return query.queryFrom(this);
}
代码示例来源:origin: com.github.seratch/java-time-backport
@SuppressWarnings("unchecked")
@Override
public
if (query == TemporalQueries.precision()) {
return (R) ChronoUnit.ERAS;
}
if (query == TemporalQueries.chronology() || query == TemporalQueries.zone() ||
query == TemporalQueries.zoneId() || query == TemporalQueries.offset() ||
query == TemporalQueries.localDate() || query == TemporalQueries.localTime()) {
return null;
}
return query.queryFrom(this);
}
代码示例来源:origin: com.github.seratch/java-time-backport
@SuppressWarnings("unchecked")
@Override
public
if (query == TemporalQueries.precision()) {
return (R) ChronoUnit.ERAS;
}
if (query == TemporalQueries.chronology() || query == TemporalQueries.zone() ||
query == TemporalQueries.zoneId() || query == TemporalQueries.offset() ||
query == TemporalQueries.localDate() || query == TemporalQueries.localTime()) {
return null;
}
return query.queryFrom(this);
}
代码示例来源:origin: com.github.seratch/java-time-backport
@SuppressWarnings("unchecked")
@Override
public
if (query == TemporalQueries.precision()) {
return (R) ChronoUnit.ERAS;
}
if (query == TemporalQueries.chronology() || query == TemporalQueries.zone() ||
query == TemporalQueries.zoneId() || query == TemporalQueries.offset() ||
query == TemporalQueries.localDate() || query == TemporalQueries.localTime()) {
return null;
}
return query.queryFrom(this);
}
代码示例来源:origin: com.github.seratch/java-time-backport
query == TemporalQueries.localDate()) {
return null;
代码示例来源:origin: com.github.seratch/java-time-backport
} else if (query == TemporalQueries.precision()) {
return (R) MONTHS;
} else if (query == TemporalQueries.localDate() || query == TemporalQueries.localTime() ||
query == TemporalQueries.zone() || query == TemporalQueries.zoneId() || query == TemporalQueries.offset()) {
return null;
代码示例来源:origin: youtongluan/sumk
@Override
public SumkDate queryFrom(TemporalAccessor temporal) {
if (temporal instanceof LocalDateTime) {
return SumkDate.of((LocalDateTime) temporal);
} else if (temporal instanceof ZonedDateTime) {
LocalDateTime dt = ((ZonedDateTime) temporal).toLocalDateTime();
return SumkDate.of(dt);
} else if (temporal instanceof OffsetDateTime) {
LocalDateTime dt = ((OffsetDateTime) temporal).toLocalDateTime();
return SumkDate.of(dt);
}
LocalDate date = temporal.query(TemporalQueries.localDate());
LocalTime time = temporal.query(TemporalQueries.localTime());
if (date == null && time == null) {
return null;
}
return SumkDate.of(date, time);
}
代码示例来源:origin: com.github.seratch/java-time-backport
@SuppressWarnings("unchecked")
@Override
public
if (query == TemporalQueries.chronology()) {
return (R) getChronology();
} else if (query == TemporalQueries.precision()) {
return (R) ChronoUnit.DAYS;
} else if (query == TemporalQueries.localDate()) {
return (R) LocalDate.ofEpochDay(toEpochDay());
} else if (query == TemporalQueries.localTime() || query == TemporalQueries.zone() ||
query == TemporalQueries.zoneId() || query == TemporalQueries.offset()) {
return null;
}
return super.query(query);
}
代码示例来源:origin: com.github.seratch/java-time-backport
@SuppressWarnings("unchecked")
@Override
public
if (query == TemporalQueries.zoneId()) {
return (R) zone;
} else if (query == TemporalQueries.chronology()) {
return (R) chrono;
} else if (query == TemporalQueries.localDate()) {
return date != null ? (R) LocalDate.from(date) : null;
} else if (query == TemporalQueries.localTime()) {
return (R) time;
} else if (query == TemporalQueries.zone() || query == TemporalQueries.offset()) {
return query.queryFrom(this);
} else if (query == TemporalQueries.precision()) {
return null; // not a complete date/time
}
// inline TemporalAccessor.super.query(query) as an optimization
// non-JDK classes are not permitted to make this optimization
return query.queryFrom(this);
}
代码示例来源:origin: com.github.seratch/java-time-backport
@SuppressWarnings("unchecked")
@Override
public
if (query == TemporalQueries.chronology()) {
return (R) getChronology();
} else if (query == TemporalQueries.precision()) {
return (R) NANOS;
} else if (query == TemporalQueries.localDate()) {
return (R) LocalDate.ofEpochDay(toLocalDate().toEpochDay());
} else if (query == TemporalQueries.localTime()) {
return (R) toLocalTime();
} else if (query == TemporalQueries.zone() || query == TemporalQueries.zoneId() || query == TemporalQueries.offset()) {
return null;
}
return super.query(query);
}
代码示例来源:origin: com.github.seratch/java-time-backport
@SuppressWarnings("unchecked")
@Override
public
if (query == TemporalQueries.zoneId() || query == TemporalQueries.zone()) {
return (R) getZone();
} else if (query == TemporalQueries.chronology()) {
return (R) toLocalDate().getChronology();
} else if (query == TemporalQueries.precision()) {
return (R) NANOS;
} else if (query == TemporalQueries.offset()) {
return (R) getOffset();
} else if (query == TemporalQueries.localDate()) {
return (R) LocalDate.ofEpochDay(toLocalDate().toEpochDay());
} else if (query == TemporalQueries.localTime()) {
return (R) toLocalTime();
}
return super.query(query);
}