To convert GregorianCalendar
to OffsetTime
, convert ZonedDateTime
and then call toOffsetTime()
method.
import java.time.OffsetTime; import java.util.GregorianCalendar; public class Main { public static void main(String[] args) { GregorianCalendar gc = new GregorianCalendar(2020, 2, 21, 15, 23, 39); // w ww .jav a 2s . c o m OffsetTime ot = gc.toZonedDateTime().toOffsetDateTime().toOffsetTime(); System.out.println("Offset Time: " + ot); } }