Java Convert ZonedDateTime to Date

Tags: Java ZonedDateTime Java Date Java 8

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

How to convert ZonedDateTime to Date in Java

In Java, to convert a ZonedDateTime object to Date object we can use these steps.

  • First step, convert ZonedDateTime object to Instant using toInstant() method.
  • Second step, create a new Date object from an Instant value using Date.from() method.
Instant instant = zonedDateTime.toInstant();
Date date = Date.from(instant);

In the following Java program we show how to convert a given ZonedDateTime object to Date object.

ConvertZonedDateTimeToDateExample1.java

import java.time.Instant;
import java.time.ZonedDateTime;
import java.util.Date;

public class ConvertZonedDateTimeToDateExample1 {
    public static void main(String... args) {
        ZonedDateTime zonedDateTime = ZonedDateTime.now();

        Instant instant = zonedDateTime.toInstant();
        Date date = Date.from(instant);

        System.out.println("ZonedDateTime: " + zonedDateTime);
        System.out.println("Date: " + date);
    }
}
The output as below.
ZonedDateTime: 2022-05-06T23:49:54.637981100+07:00[Asia/Bangkok]
Date: Fri May 06 23:49:54 ICT 2022

Happy Coding 😊

Java Convert ZonedDateTime to Instant

Java Convert ZonedDateTime to Calendar

Java Convert ZonedDateTime to LocalDateTime

Java Convert ZonedDateTime to OffsetDateTime

Java Convert ZonedDateTime to LocalTime

Java Convert ZonedDateTime to LocalDate

Java Convert ZonedDateTime to ZoneOffset

Java Convert ZonedDateTime to ZoneId

Java Convert ZonedDateTime to Epoch Seconds

Java Convert ZonedDateTime to String

Java Convert String to ZonedDateTime