Convert ZonedDateTime to LocalDate Example

ZonedDateTime class provide toLocalDate() API to convert from ZonedDateTime to LocalDate in Java.

Convert ZonedDateTime to LocalDate Example

import java.time.LocalDate;
import java.time.ZonedDateTime;

/**
 * Program to demonstrate ZonedDateTime Class APIs.
 * @author javaguides.net
 *
 */
public class ZonedDateTimeExample {
 
    public static void main(String[] args) {
         getInstances();
    }

    private static void getInstances() {
       // Current date time with zone
        ZonedDateTime dateTime = ZonedDateTime.now();
        System.out.println(dateTime);

       // Get LocalDate
        LocalDate localDate = dateTime.toLocalDate();
        System.out.println(localDate);
    }
}

Output:

2019-06-16T13:33:25.755Z[Etc/UTC]
2019-06-16

Reference

Comments