instant是瞬间的意思
package com.itheima.d4_jdk8_time;
import java.time.Instant;
import java.time.ZoneId;
import java.util.Date;
public class Demo01Instant {
public static void main(String[] args) {
// 1.得到一个Instant时间戳对象
Instant instant = Instant.now(); // 利用时间戳API创建对象,调用功能
System.out.println(instant); // 输出当前时间戳 //2022-05-01T17:28:28.327775700Z 不标准,相差了时间
// 2.系统此刻的时间戳怎么办?
Instant instant1 = Instant.now();
System.out.println(instant1.atZone(ZoneId.systemDefault())); // 获取当前时区的系统默认时间
// 3. 如何去返回Date对象
Date date = Date.from(instant); // 获取当前时间戳的日期时间(返回类型是Date)
System.out.println(date);
}
}