Java Convert Instant to ZonedDateTime

Tags: Java Instant Java ZonedDateTime Java 8

In this Java core tutorial we learn how to convert a java.time.Instant object into a java.time.ZonedDateTime object in Java programming language.

How to convert Instant to ZonedDateTime in Java

In Java, with a given Instant object we can use the ZonedDateTime.ofInstant(Instant instant, ZoneId zone) static method to convert it to a ZonedDateTime object with system time zone as the following example Java code.

ConvertInstantToZonedDateTimeExample1.java

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

public class ConvertInstantToZonedDateTimeExample1 {
    public static void main(String... args) {
        Instant instant = Instant.now();

        ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(instant, ZoneId.systemDefault());

        System.out.println("Instant: " + instant);
        System.out.println("ZonedDateTime: " + zonedDateTime);
    }
}
The output as below.
Instant: 2022-05-17T16:37:05.125807100Z
ZonedDateTime: 2022-05-17T23:37:05.125807100+07:00[Asia/Bangkok]

Happy Coding 😊

Java Convert Instant to Calendar

Java Convert Instant to Date

Java Convert Instant to LocalDateTime

Java Convert Instant to LocalDate

Java Convert Instant to LocalTime

Java Convert Instant to OffsetDateTime

Java Convert Instant to Epoch Seconds

Java Convert Instant to Epoch Milliseconds

Java Convert Instant to String

Java Convert String to Instant