The method for defining the zone ID for IST time using atZone(Zone_ID) in Java is as follows:
LocalDateTime dateTime = LocalDateTime.now();
ZoneId istZone = ZoneId.of("Asia/Kolkata");
ZonedDateTime istDateTime = dateTime.atZone(istZone);
In the above code, we first create a LocalDateTime object using the now()
method. We then define the IST time zone using the of()
method of the ZoneId class. Finally, we use the atZone()
method of the LocalDateTime class to create a ZonedDateTime object with the specified time zone.
Asked: 2022-05-20 11:00:00 +0000
Seen: 8 times
Last updated: Sep 08 '21