0

Is there any way to apply the changed timezone in real time while running a Java application in a Unix environment?

The following sources do not work on unix!!

[in Linux]

   TimeZone.setDefault(null);
    System.clearProperty("user.timezone");
안지표
  • 1
  • 1
  • 2
    What do you mean by changed timezone in real time? Are you asking about Daylight Savings Time? Because if you are, that is not a change of timezone, it's a change of time offset, but the timezone remains the same. Why would the timezone be changing while your program is running? – Andreas May 09 '18 at 02:15
  • There is a function that operates according to the system time. In some cases, the server administrator changes the localtime zone of the server while the process is running. So the function does not work as intended, so I am looking for a way to apply the changed system timezone. – 안지표 May 09 '18 at 02:21
  • I think you should question why the administrator changes the timezone at all. The server hasn't moved. Requiring program to reach to a server change, without just restarting the program, seems like an XY problem. – Andreas May 09 '18 at 02:25
  • What I really need is a calendar with the current system's timezone. I want to get a calendar object that corresponds to a time zone that is unexpectedly changed from time to time after the Java process is started – 안지표 May 09 '18 at 02:26
  • My client's server person is changing the time zone so I can not get involved in his work so I have to fix it – 안지표 May 09 '18 at 02:32
  • Can't you just tell them to restart the program, if something as fundamental as the timezone changes? – Andreas May 09 '18 at 02:38
  • There are a lot of people who have permissions on the server and they only have the privilege to operate the server and the authority to control the application can not be done by someone else – 안지표 May 09 '18 at 02:40
  • Thank you for kindly responding to the sentence would be awkward because I could not use English well. – 안지표 May 09 '18 at 02:42
  • Ok, then from Java you should run a linux command that outputs the timezone, and have your Java code read/parse that output, e.g. run `datetimectl`. – Andreas May 09 '18 at 02:45

0 Answers0