To convert GregorianCalendar
to ZonedDateTime
, call toZonedDateTime()
method.
import java.time.ZonedDateTime; import java.util.GregorianCalendar; public class Main { public static void main(String[] args) { GregorianCalendar gc = new GregorianCalendar(2020, 2, 21, 15, 23, 39); /*w w w. ja v a 2 s . c om*/ ZonedDateTime zdt = gc.toZonedDateTime(); System.out.println("Zoned DateTime: " + zdt); } }