Java中的LocalDateTime query()方法
可以根据需要使用Java中LocalDateTime类中的查询方法查询LocalDateTime对象。此方法需要单个参数,即要调用的查询,并且它返回查询的结果。
演示此的程序如下所示-
示例
import java.time.*;
import java.time.temporal.*;
public class Demo {
public static void main(String[] args) {
LocalDateTime ldt = LocalDateTime.parse("2019-02-18T23:15:30");
System.out.println("The LocalDateTime is: " + ldt);
String precision = ldt.query(TemporalQueries.precision()).toString();
System.out.println("The Precision for the LocalDateTime is: "+ precision);
}
}输出结果
The LocalDateTime is: 2019-02-18T23:15:30 The Precision for the LocalDateTime is: Nanos
现在让我们了解上面的程序。
首先显示LocalDateTime对象。然后使用该query()方法查询LocalDateTime对象,并显示查询结果。演示这的代码片段如下-
LocalDateTime ldt = LocalDateTime.parse("2019-02-18T23:15:30");
System.out.println("The LocalDateTime is: " + ldt);
String precision = ldt.query(TemporalQueries.precision()).toString();
System.out.println("The Precision for the LocalDateTime is: "+ precision);热门推荐
1 训练狗狗工作
4 狗狗定点排便训练
5 狗狗训练吠叫
6 狗狗尿垫训练
7 狗狗训练座
8 狗狗训练攻略
9 狗狗训练记
10 做训练狗狗
11 狗狗训练词
12 狗狗谢谢怎么训练
13 狗狗训练如厕
14 狗狗太凶怎么训练
15 狗狗训练它
16 狗狗克制训练
17 训练基地狗狗
18 怎么样训练狗狗大小硬