Convert Between Time Zones
With time zones a given timestamp can be represented in different local dates
and times.
Since Java 8
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.util.List;
public class ConvertBetweenTimeZones {
public static void main(String... args) {
ZonedDateTime lunarEclipse = ZonedDateTime.of(LocalDate.of(2025, 03, 14), LocalTime.of(6, 59), ZoneOffset.UTC);
List<String> places = List.of( //
"Asia/Tokyo", "Asia/Kolkata", "Europe/Paris", "America/Fortaleza", "Pacific/Honolulu");
for (String place : places) {
System.out.println("Lunar Eclipse at " + lunarEclipse.withZoneSameInstant(ZoneId.of(place)));
}
}
}
This snippet at GitHub