ZonedDateTime class provides toLocalDateTime() API to convert ZonedDateTime to LocalDateTime in Java.
import java.time.LocalDateTime; 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 LocalDateTime LocalDateTime localDateTime = dateTime.toLocalDateTime(); System.out.println(localDateTime); } }Output:
2019-06-16T13:24:50.801Z[Etc/UTC]
2019-06-16T13:24:50.801
Comments
Post a Comment