I want to get local time of different time zones using Java code. Based on the time zone passed to the function I need that time zone\'s local time. How to achieve this?
In Java 8, you can use the ZonedDateTime.now(ZoneId zone) method:
ZonedDateTime zonedDateTime = ZonedDateTime.now(ZoneId.of("Asia/Tokyo")); LocalTime localTime = zonedDateTime.toLocalTime(); System.out.println(localTime);