Java Convert ZonedDateTime to LocalDate
Tags: Java ZonedDateTime Java LocalDate Java 8
In this Java core tutorial we learn how to convert a java.time.ZonedDateTime object into java.time.LocalDate object in Java programming language.
How to convert ZonedDateTime to LocalDate in Java
In Java, to convert a ZonedDateTime object to LocalDate object we can use the ZonedDateTime.toLocalDate() method as the Java program below.
ConvertZonedDateTimeToLocalDateExample1.java
import java.time.LocalDate;
import java.time.ZonedDateTime;
public class ConvertZonedDateTimeToLocalDateExample1 {
public static void main(String... args) {
ZonedDateTime zonedDateTime = ZonedDateTime.now();
LocalDate localDate = zonedDateTime.toLocalDate();
System.out.println("ZonedDateTime: " + zonedDateTime);
System.out.println("LocalDate: " + localDate);
}
}
ZonedDateTime: 2022-05-07T00:14:22.292402700+07:00[Asia/Bangkok]
LocalDate: 2022-05-07
Happy Coding 😊
Related Articles
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 LocalTime
Java Convert ZonedDateTime to ZoneOffset
Java Convert ZonedDateTime to ZoneId
Java Convert ZonedDateTime to Epoch Seconds