Java中的LocalTime ofNanoOfDay()方法
可以使用ofNanoOfDay()Java中LocalTime类中的方法,使用一天中的纳秒来获取LocalTime对象。此方法需要一个参数,即一天的纳秒,它返回一天的纳秒的LocalTime对象
演示此程序如下
示例
import java.time.*;
public class Demo {
public static void main(String[] args){
long nanoSeconds = 1000000000;
System.out.println("The nanoseconds of the day: " + nanoSeconds);
System.out.println("The LocalTime is: " + LocalTime.ofNanoOfDay(nanoSeconds));
}
}输出
The nanoseconds of the day: 1000000000 The LocalTime is: 00:00:01
现在让我们了解上面的程序。
首先显示一天的纳秒。然后,使用该ofNanoOfDay()方法以一天中的纳秒为单位获取LocalTime对象并进行打印。演示此代码段如下所示:
long nanoSeconds = 1000000000;
System.out.println("The nanoseconds of the day: " + nanoSeconds);
System.out.println("The LocalTime is: " + LocalTime.ofNanoOfDay(nanoSeconds));热门推荐
1 狗狗技能训练
5 如何训练狗狗笑
6 狗狗训练排便
9 狗狗响片训练
10 如何训练狗狗不捡食
11 狗狗尿训练
12 怎么训练狗狗找东西
13 狗狗训练站立
14 狗狗训练飞盘
15 鞍山狗狗训练
16 怎样训练泰迪狗狗谢谢
17 狗狗外出训练
18 怎么训练金毛狗狗大小便