We have a java programm which uses the -Duser.timezone parameter at startup:
-Duser.timezone=”CET”
This is neccessary because we can’t rely on the servers internal clock (admins playing around, setting wrong timezones and so on, don’t ask 🙁 ) and it is important that the timezone of the frontend matches the backend.
As this program is not restarted regularly (it is a server) I was wondering what happens when we switch from winter- to summertime? Does it switch automatically or do we have to restart the server?
Thanks and regards,
Alex
Edit: It might be possible that java determines the correct timezone with ervery call to a function which uses dates. But it might also be possible that java determines the correct timezone once at startup.
The time in Java is just a simple long value (milliseconds since 1970) without any information about the time zone. The
java.util.Dateandjava.sql.Datealso store the date/time internally as milliseconds since 1970, but with UTC time zone.The time zone comes into play, when you format a date/time for output or when you parse a date/time from a string. The time zone information you set via
-Duser.timezonewill be used at that time.So it should work and a little test also shows it:
using
-Duser.timezone=GMTit will print: (no switch)using
-Duser.timezone=CETit will print: (switch at 2am)using
-Duser.timezone=EETit will print: (Eastern European Time, one hour after CET)