一、介绍
- Instant类由一个静态的工厂方法now()可以返回当前时间戳
- 时间戳是包含日期和时间的,与java.util.Date很类似,事实上Instant就是类似JDK8以前的Date
- Instant和Date这两个类可以进行转换
二、实例
publicstaticvoidmain(String[] args){
Instant instant= Instant.now();
System.out.println("当前时间戳是:"+instant);
Date date= Date.from(instant);
System.out.println("当前时间戳是:"+date);
instant= date.toInstant();
System.out.println("当前时间戳是:"+instant);}