package com.gochinatv.cdn.api.jdk.jdk8;

import java.time.Duration;
import java.time.Instant;
import java.time.ZoneId;

/**
 * 
 * https://dotnetcodr.com/2015/01/11/formatting-dates-in-java-8-using-datetimeformatter/
 * @author jacktomcat
 * 
 * Instant类是用在机器可读的时间格式上的，它以Unix时间戳的形式存储日期时间
 *
 */
public class InstantTest {
   
	public static void main(String[] args) {
        
		System.out.println("=====================Instant=======================");
        Instant instant = Instant.now();
        instant.atZone(ZoneId.of("Asia/Shanghai"));
        System.out.println("Instant now = " + instant);
        System.out.println("Instant EPOCH = " + Instant.EPOCH);
        System.out.println("Instant toEpochMilli = " + instant.toEpochMilli());

        //Instant from timestamp
        Instant specificTime = Instant.ofEpochMilli(1500978707350L);
        System.out.println("Specific Time = "+specificTime);
 
        //Duration example
        //Duration thirtyDay = Duration.ofDays(30);
        //System.out.println(thirtyDay);
	}
}

@@ -91,16 +91,78 @@
 stant;%0D%0A
+import java.time.LocalDate;%0D%0Aimport java.time.LocalDateTime;%0D%0A
 import j
@@ -824,16 +824,26 @@
 illi());
+//%E7%B3%BB%E7%BB%9F%E5%BD%93%E5%89%8D%E7%9A%84%E6%97%B6%E9%97%B4%E6%88%B3
 %0D%0A%0D%0A    
@@ -931,18 +931,18 @@
 (150
-0978707350
+1034909184
 L);%0D
@@ -1035,34 +1035,32 @@
 xample%0D%0A        
-//
 Duration thirtyD
@@ -1085,53 +1085,649 @@
 ys(3
-0);%0D%0A        //System.out.println(thirtyDay);
+);%0D%0A        System.out.println(thirtyDay);%0D%0A        %0D%0A        LocalDateTime localDate1 = LocalDateTime.of(2017, 7, 1,1,1,1);%0D%0A        LocalDateTime localDate2 = LocalDateTime.of(2017, 7, 1,2,1,1);%0D%0A        %0D%0A        Duration between = Duration.between(localDate1, localDate2);%0D%0A        long millis = between.toMillis();%0D%0A        long seconds = between.getSeconds();%0D%0A        System.out.println(%22Duration between millis = %22+ millis);%0D%0A        System.out.println(%22Duration between seconds = %22+ seconds);%0D%0A        %0D%0A        Instant plus3Day = instant.plus(thirtyDay);%0D%0A        System.out.println(%22Instant plus 3 days = %22+ plus3Day);//%E5%8A%A0%E4%BA%86%E4%B8%89%E5%A4%A9%E4%B9%8B%E5%90%8E%E7%9A%84%E6%97%B6%E9%97%B4%E6%88%B3
 %0D%0A%09%7D

add Instant support