热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

java.time.temporal.TemporalQueries.localDate()方法的使用及代码示例

本文整理了Java中java.time.temporal.TemporalQueries.localDate()方法的一些代码示例,展示了TemporalQ

本文整理了Java中java.time.temporal.TemporalQueries.localDate()方法的一些代码示例,展示了TemporalQueries.localDate()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TemporalQueries.localDate()方法的具体详情如下:
包路径:java.time.temporal.TemporalQueries
类名称:TemporalQueries
方法名:localDate

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 R query(TemporalQuery query) {
if (query == TemporalQueries.localDate()) {
return (R) isoDate;
}
return super.query(query);
}

代码示例来源:origin: com.nhl.link.rest/link-rest-base

private Optional getLocalDate(TemporalAccessor parsed) {
return Optional.ofNullable(parsed.query(TemporalQueries.localDate()));
}

代码示例来源:origin: agrestio/agrest

private Optional getLocalDate(TemporalAccessor parsed) {
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 the type of the result
* @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 R query(TemporalQuery query) {
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 the type of the result
* @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 R query(TemporalQuery query) {
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 R query(TemporalQuery query) {
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 R query(TemporalQuery query) {
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 R query(TemporalQuery query) {
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 R query(TemporalQuery query) {
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 R query(TemporalQuery query) {
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 R query(TemporalQuery query) {
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 R query(TemporalQuery query) {
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 R query(TemporalQuery query) {
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 R query(TemporalQuery query) {
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);
}

推荐阅读
  • ListView简单使用
    先上效果:主要实现了Listview的绑定和点击事件。项目资源结构如下:先创建一个动物类,用来装载数据:Animal类如下:packagecom.example.simplelis ... [详细]
  • 本文将详细探讨 Java 中提供的不可变集合(如 `Collections.unmodifiableXXX`)和同步集合(如 `Collections.synchronizedXXX`)的实现原理及使用方法,帮助开发者更好地理解和应用这些工具。 ... [详细]
  • 最近同事提了一个需求过来,他觉得项目对于第三方日志记录的太多了,只想记录一些业务相关的日志减少对于框架日志的显示。具体要求就是对于框架日志只显示warn等级以上的,而业务日志显示info等级以上 ... [详细]
  • 本文详细介绍了如何在 Android 中使用值动画(ValueAnimator)来动态调整 ImageView 的高度,并探讨了相关的关键属性和方法,包括图片填充后的高度、原始图片高度、动画变化因子以及布局重置等。 ... [详细]
  • 本文详细探讨了Java中的ClassLoader类加载器的工作原理,包括其如何将class文件加载至JVM中,以及JVM启动时的动态加载策略。文章还介绍了JVM内置的三种类加载器及其工作方式,并解释了类加载器的继承关系和双亲委托机制。 ... [详细]
  • 本文探讨了如何通过一系列技术手段提升Spring Boot项目的并发处理能力,解决生产环境中因慢请求导致的系统性能下降问题。 ... [详细]
  • java文本编辑器,java文本编辑器设计思路
    java文本编辑器,java文本编辑器设计思路 ... [详细]
  • 烤鸭|本文_Spring之Bean的生命周期详解
    烤鸭|本文_Spring之Bean的生命周期详解 ... [详细]
  • 本文探讨如何利用Java反射技术来模拟Webwork框架中的URL解析过程。通过这一实践,读者可以更好地理解Webwork及其后续版本Struts2的工作原理,尤其是它们在MVC架构下的角色。 ... [详细]
  • 深入剖析JVM垃圾回收机制
    本文详细探讨了Java虚拟机(JVM)中的垃圾回收机制,包括其意义、对象判定方法、引用类型、常见垃圾收集算法以及各种垃圾收集器的特点和工作原理。通过理解这些内容,开发人员可以更好地优化内存管理和程序性能。 ... [详细]
  • Django Token 认证详解与 HTTP 401、403 状态码的区别
    本文详细介绍了如何在 Django 中配置和使用 Token 认证,并解释了 HTTP 401 和 HTTP 403 状态码的区别。通过具体的代码示例,帮助开发者理解认证机制及权限控制。 ... [详细]
  • 在寻找轻量级Ruby Web框架的过程中,您可能会遇到Sinatra和Ramaze。两者都以简洁、轻便著称,但它们之间存在一些关键区别。本文将探讨这些差异,并提供详细的分析,帮助您做出最佳选择。 ... [详细]
  • springMVC JRS303验证 ... [详细]
  • 在Java应用程序开发过程中,FTP协议被广泛用于文件的上传和下载操作。本文通过Jakarta Commons Net库中的FTPClient类,详细介绍如何实现文件的上传和下载功能。 ... [详细]
  • ▶书中第四章部分程序,包括在加上自己补充的代码,有边权有向图的邻接矩阵,FloydWarshall算法可能含负环的有边权有向图任意两点之间的最短路径●有边权有向图的邻接矩阵1 ... [详细]
author-avatar
小邵Bans_530
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有