I have a simple Java Executor thread running. This just detects the time zone and displays.
The code is as follows :
ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor();
exec.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
TimeZone.setDefault(null);
//get Calendar instance
Calendar now = Calendar.getInstance();
//get current TimeZone using getTimeZone method of Calendar class
TimeZone timeZone = now.getTimeZone();
//display current TimeZone using getDisplayName() method of TimeZone class
System.out.println("Current TimeZone is : " + timeZone.getDisplayName());
System.out.println( System.getProperty( "user.timezone" ) );
}
}, 0, 10, TimeUnit.SECONDS);
The problem is, if I modify the time zone alone manually using the control panel.My time zone is not getting updated.
I have read a post explaining JVM time issue Java System.getProperty( "user.timezone" ) does not work
Now i need to detect system time zone change