一、簡介
用於“時間戳”的運算。它是以Unix元年(傳統 的設定為UTC時區1970年1月1日午夜時分)開始 所經歷的描述進行運算
二、文檔介紹


1、now

1 Instant instantNow = Instant.now(); 2 3 System.out.println("instant獲取當前yyyy-mm-dd :\n" + instantNow); 4 5 Clock clock = Clock.systemDefaultZone(); 6 7 Instant instantClock = Instant.now(clock); 8 9 System.out.println("instantClock獲取當前yyyy-mm-dd :\n" + instantClock); 10 11 Instant localDateGet = Instant.now(); 12 13 System.out.println("從1970-01-01T00:00:00Z開始的秒數 :\n" + localDateGet.getEpochSecond()); 14 System.out.println("localDateGet獲取當前是本月的第幾天 :\n" + localDateGet.atZone(ZoneId.of("GMT+8", new HashMap<>(64))));
2、ofEpochSecond

1 Instant instantEpochSecond = Instant.ofEpochSecond(200); 2 System.out.println("從1970-01-01T00:00:00Z的秒數:\n" + instantEpochSecond);
3、ofEpochMilli

1 Instant instantEpochMilli = Instant.ofEpochMilli(600); 2 System.out.println("從1970-01-01T00:00:00Z的毫秒數:\n" + instantEpochMilli);
4、from

1 Instant localDateFormatNow = Instant.from(ZonedDateTime.now()); 2 System.out.println("當前日期是:\n" + localDateFormatNow);
5、parse

1 Instant instantText = Instant.parse("2007-12-03T10:15:30.00Z"); 2 System.out.println("instantText輸出字符串日期 :\n" + instantText);
6、最大值和最小值
1 Instant instantMax = Instant.MAX; 2 System.out.println("instantMax年的最大取值范圍 :\n" + instantMax); 3 4 Instant instantMin = Instant.MIN; 5 System.out.println("instantMin年的最小取值范圍 :\n" + instantMin);
