Compare the same time in different time zone
Description
The following code shows how to Compare the same time in different time zone.
Example
import java.time.LocalTime;
import java.time.ZoneId;
/*from w w w .java 2s .c o m*/
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);
System.out.println(now1.isBefore(now2)); // false
}
}
The code above generates the following result.