+ 1
Java ZonedDateTime does not adjust UTC to local zone
How can I print the adjusted time? I expect the result to be 2021-08-11T04:15.
2 Respuestas
+ 1
change zone of ZonedDateTime:
//import java.time.ZoneId;
//import java.time.ZonedDateTime;
ZonedDateTime timeUTC = ZonedDateTime.now( ZoneId.of("UTC"));
ZoneId localZone = ZoneId.of("Africa/Lagos"); //UTC +1h
ZonedDateTime timeZoned = timeUTC.withZoneSameInstant( localZone);
System.out.println( timeUTC);
System.out.println( timeZoned);