java.time.Instant.atZone() 方法示例


java.time.Instant.atZone() 方法示例

package com.codingdict;

import java.time.Instant;
import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.util.Set;

public class InstantDemo {
   public static void main(String[] args) {

      Instant instant = Instant.parse("2017-02-03T10:37:30.00Z");
      System.out.println(instant);  

      Set<String> zones = ZoneId.getAvailableZoneIds();

      ZoneId zone = ZoneId.of(zones.iterator().next());

      ZonedDateTime  date = instant.atZone(zone);
      System.out.println(date);  
   }
}