Java程序从纪元和毫秒创建Instant
从纪元创建即时
示例
import java.time.Instant; public class Demo { public static void main(String[] args) { Instant instant = Instant.ofEpochSecond(282829279); System.out.println(instant); } }
输出结果
1978-12-18T11:41:19Z
从纪元毫秒创建即时
示例
import java.time.Instant; public class Demo { public static void main(String[] args) { Instant instant = Instant.ofEpochMilli(272827282728l); System.out.println(instant); } }
输出结果
1978-08-24T17:21:22.728Z