Java Data Type How to - Get ZonedDateTime from specific Calendar








Question

We would like to know how to get ZonedDateTime from specific Calendar.

Answer

//ww w  . j a v  a  2s . c o m
import java.time.ZonedDateTime;
import java.util.GregorianCalendar;

public class Main {
    public static void main(String[] args) {
      // ZonedDateTime from specific Calendar
      ZonedDateTime gregorianCalendarDateTime = new GregorianCalendar()
              .toZonedDateTime();
      System.out.println(gregorianCalendarDateTime);
    }
}

The code above generates the following result.