Java Convert ZonedDateTime to LocalTime

Tags: Java ZonedDateTime Java LocalTime Java 8

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

How to convert ZonedDateTime to LocalTime in Java

In Java, to convert a ZonedDateTime object to LocalTime object we can use the ZonedDateTime.toLocalTime() method as the Java program below.

ConvertZonedDateTimeToLocalTimeExample1.java

import java.time.LocalTime;
import java.time.ZonedDateTime;

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

        LocalTime localTime = zonedDateTime.toLocalTime();

        System.out.println("ZonedDateTime: " + zonedDateTime);
        System.out.println("LocalTime: " + localTime);
    }
}
The output as below.
ZonedDateTime: 2022-05-07T00:12:34.066674900+07:00[Asia/Bangkok]
LocalTime: 00:12:34.066674900

Happy Coding 😊

Java Convert ZonedDateTime to Instant

Java Convert ZonedDateTime to Date

Java Convert ZonedDateTime to Calendar

Java Convert ZonedDateTime to LocalDateTime

Java Convert ZonedDateTime to OffsetDateTime

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