Java Data Type How to - Convert ZonedDateTime to Calendar








Question

We would like to know how to convert ZonedDateTime to Calendar.

Answer

import java.time.ZonedDateTime;
import java.util.GregorianCalendar;
//from   w  ww  .  j av  a  2s .  c  o m
public class Main {
  public static void main(String[] args) {
    ZonedDateTime gregorianCalendarDateTime = new GregorianCalendar()
        .toZonedDateTime();

    GregorianCalendar gc = GregorianCalendar.from(gregorianCalendarDateTime);
    System.out.println(gc);
  }
}

The code above generates the following result.