Close

Java Date Time - Instant.atZone() Examples

Java Date Time Java Java API 


Class:

java.time.Instant

java.lang.Objectjava.lang.Objectjava.time.Instantjava.time.Instantjava.time.temporal.TemporalTemporaljava.time.temporal.TemporalAdjusterTemporalAdjusterjava.lang.ComparableComparablejava.io.SerializableSerializableLogicBig

Method:

public ZonedDateTime atZone(ZoneId zone)

This methods returns a new instance of ZonedDateTime created from the fields of this instant at the specified time-zone.


Examples


package com.logicbig.example.instant;

import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;

public class AtZoneExample {

public static void main(String... args) {
Instant i = Instant.parse("2017-04-09T10:15:30.00Z");
System.out.println(i);

ZonedDateTime d = i.atZone(ZoneId.of("America/Jamaica"));
System.out.println(d);
}
}

Output

2017-04-09T10:15:30Z
2017-04-09T05:15:30-05:00[America/Jamaica]




See Also