package com.njust.test.java8;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;

import org.junit.Test;

public class InstantDemo
{
    /**
     * <pre>
     * 2020-10-10T16:59:38.699
     * 2020-10-10T08:59:38.700Z
     * 2020-10-10T14:59:38.700+06:00
     * 2020-10-10T08:59:38.700Z
     * </pre>
     */
    @Test
    public void test01()
    {
        System.out.println(LocalDateTime.now());
        
        //1.默认是UTC时间的
        Instant instant = Instant.now();
        System.out.println(instant);
        
        OffsetDateTime offsetDateTime1 = instant.atOffset(ZoneOffset.of("+6"));
        System.out.println(offsetDateTime1);
        
        OffsetDateTime offsetDateTime2 = instant.atOffset(ZoneOffset.UTC);
        System.out.println(offsetDateTime2);
    }
}

@@ -24,16 +24,40 @@
 java8;%0A%0A
+import java.time.Clock;%0A
 import j
@@ -74,16 +74,16 @@
 nstant;%0A
-
 import j
@@ -131,32 +131,57 @@
 OffsetDateTime;%0A
+import java.time.ZoneId;%0A
 import java.time
@@ -253,16 +253,923 @@
     /**%0A
+     * instant%E6%80%BB%E6%98%AFUTC%E7%9A%84%0A     * %3Cpre%3E%0A     * 2020-10-12T02:07:40.332Z%0A     * 2020-10-12T02:07:40.367Z%0A     * 2020-03-19T01:50:16.394Z%0A     * 2020-10-09T09:29:45.440Z%0A     * %3C/pre%3E%0A     */%0A    @Test%0A    public void createInstant()%0A    %7B%0A        //1.Instant.now%E6%80%BB%E6%98%AF%E7%9B%B8%E5%90%8C%E7%9A%84%0A        Instant instant1 = Instant.now();%0A        System.out.println(instant1);%0A        %0A        Instant instant2 = Instant.now(Clock.system(ZoneId.of(%22+8%22)));%0A        System.out.println(instant2);%0A        %0A        //%E5%8F%AF%E4%BB%A5%E5%B0%86OffsetDateTime%E8%BD%AC%E6%8D%A2%E6%88%90Instant%0A        OffsetDateTime offsetDateTime = OffsetDateTime.parse(%222020-03-19T01:50:16.394Z%22);%0A        Instant instant3 = offsetDateTime.toInstant();%0A        System.out.println(instant3);%0A        %0A        OffsetDateTime offsetDateTime1 = OffsetDateTime.parse(%222020-10-09T17:29:45.440+08:00%22);%0A        Instant instant4 = offsetDateTime1.toInstant();%0A        System.out.println(instant4);%0A    %7D%0A    %0A    /**%0A
      * %3C
@@ -1357,14 +1357,30 @@
 oid 
-test01
+instant2OffsetDateTime
 ()%0A 

Update InstantDemo.java