I want to be sure that my Java program is always run by explicitly specified user.timezone property. I pass -Duser.timezone=XXX as a command-line setting.
However, when I omit that system property at all, and then in my program I check the value of System.getProperty("user.timezone"), it is not null, instead, it contains the system timezone. So, I can't terminate my program, as the value of that property is never null.
I know that I can use a custom system property name(say tz) to accept the timezone ID and then execute TimeZone.setDefault(System.getProperty("tz")) in my code, but I prefer to use the system property user.timezone, which is intended to be used for that reason.
Is there any way to achieve what I need using user.timezone system property ?