Building timezone objects in Java
I use the timezone string to build Java timezone objects, such as GMT-8, GMT, PST, EST, etc
So if I get inputs like PST and daylightsaving to be true, I have to change the string to PDT Worse, sometimes I get input like GMT-8 or gmt-6, where the day light flag is true or false Is there a way out?
I cannot use third-party timezone related classes
Code example:
TimeZone timeZone = TimeZone.getTimeZone("EST"); TimeZone timeZone = TimeZone.getTimeZone("PST"); TimeZone timeZone = TimeZone.getTimeZone("GMT-8");
Solution
I think Java should find out for itself whether the time zone is using daylight saving time and when it is active
Therefore, if you try to format a date object with this time zone, the output should reflect daylight saving time
I don't know whether this is reliable (in view of the frequent changes in this area) You should update to the latest JVM to get the latest time zone database file (if you cannot do so, you can use the separate time zone update tool)