How can I get the operating system Time Zone in Java?
TimeZone.getDefault () returns the system time zone before it was changed.
Example 1:
System.out.println(TimeZone.getDefault());
Result:
Europe/Kaliningrad
This is the system time zone.
Example 2:
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Kolkata"));
System.out.println(TimeZone.getDefault());
Result:
Asia/Kolkata
This is not the system time zone, the system time zone is still in Europe / Kaliningrad.
So how can I get the system timezone even after changing the default DateTimeZone.
+3
source to share