java8中的时间处理4 - Instant
程序员文章站
2022-03-08 18:25:51
...
Instant 类是机器易读的时间信息,存放的是unix时间戳。
import java.time.Duration; import java.time.Instant; public class InstantExample { public static void main(String[] args) { Instant timestamp = Instant.now(); System.out.println("当前时间 = "+timestamp); Instant specificTime = Instant.ofEpochMilli(timestamp.toEpochMilli()); System.out.println("特定时间 = "+specificTime); //时间段 Duration thirtyDay = Duration.ofDays(30); System.out.println(thirtyDay); } }
推荐阅读
-
python 处理dataframe中的时间字段方法
-
JS中处理与当前时间间隔的函数代码
-
Python中时间datetime的处理与转换用法总结
-
Python中基本的日期时间处理的学习教程
-
Python3中常用的处理时间和实现定时任务的方法的介绍
-
Python中处理时间的几种方法小结
-
python中关于日期时间处理的问答集锦
-
mysql中对于时间的处理,时间的滚动,求时间间隔,切换时区等等
-
Java日期时间API系列11-----Jdk8中java.time包中的新的日期时间API类,使用java8日期时间API重写农历LunarDate
-
JS中处理时间之setUTCMinutes()方法的使用