Get local time for different time zone
Description
The following code shows how to Get local time for different time zone.
Example
import java.time.LocalTime;
import java.time.ZoneId;
/*from www . ja va 2 s .c om*/
public class Main {
public static void main(String... args) {
ZoneId zone1 = ZoneId.of("Europe/Berlin");
ZoneId zone2 = ZoneId.of("Brazil/East");
LocalTime now1 = LocalTime.now(zone1);
LocalTime now2 = LocalTime.now(zone2);
System.out.println(now1);
System.out.println(now2);
}
}
The code above generates the following result.