/**
* java.time.Instant jdk1.8
* public final class Instant
implements Temporal, TemporalAdjuster, Comparable<Instant>, Serializable {}
方法:
now():从系统时钟中获得当前时刻。
getEpochSecond():返回秒数;
ofEpochMilli(long epochMilli);返回毫秒 Instant实例
转换:Instant ----> util.Date
util.Date ---> Instant
String ------> Instant
*/
Instant now1=Instant.now();//2019-07-19T01:25:22.894Z
long epochSecond = now1.getEpochSecond();//返回秒数;
//Instant---->util.Date
Date date = new Date(epochSecond*1000);//毫秒数
/*使用SimpleDateFormat 格式化*/
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String format = sdf.format(date);
System.out.println(format);
//util.Date---->Instant
Date date2 = new Date();
long time = date2.getTime();//返回毫秒
Instant ofEpochMilli = Instant.ofEpochMilli(time);//返回毫秒 Instant实例
long epochSecond2 = ofEpochMilli.getEpochSecond();//返回秒数
String format2 = sdf.format(new Date(epochSecond2*1000));
System.out.println(format2);
//String---->Instant
Instant parse4 = Instant.parse("2019-07-12T07:15:08.564Z");
System.out.println(parse4);