The TimeZone.getDefault() returns the System Time zone until it's changed.
Sample 1:
System.out.println(TimeZone.getDefault());
Result:
Europe/Kaliningrad
It is system time zone.
Sample 2:
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Kolkata"));
System.out.println(TimeZone.getDefault());
Result:
Asia/Kolkata
It isn't system time zone, system time zone is still Europe/Kaliningrad.
So how can I get system time zone even after change default DateTimeZone.
You can check system property user.timezone:
System.getProperty("user.timezone")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With