I am creating a Java TimeZone object using a TimeZone string such as GMT-8, GMT, PST, EST, etc. This did not take into account whether the time zone is enabled or not. Now there is a requirement to enable this check, and instead of entering as PDT or EDT, daylight saving time is set as a separate flag. I'm not sure if TimeZone has a direct method to change the DayLight property of saving this TimeZone.
So if I get inputs like PST and DaylightSaving as true, then I need to change the string as PDT. Which is even worse, sometimes I get inputs like GMT-8 or GMT-6 with the Day Day flag as true or false. Is there a way out?
I can not use third-party classes related to TimeZone
Code example:
TimeZone timeZone = TimeZone.getTimeZone("EST");
TimeZone timeZone = TimeZone.getTimeZone("PST");
TimeZone timeZone = TimeZone.getTimeZone("GMT-8");
source
share