Building TimeZone object in Java
- by Harish
I build a Java TimeZone object using the TimeZone String like GMT-8,GMT,PST,EST etc.
This did not consider whether the timezone is daylight saving enabled or not.Now there is a requirement to include this check and instead of giving the input as PDT or EDT the daylight saving is given as a seperate flag.I am not sure whether TimeZone has a direct method to change the dayLight saving property of that TimeZone.
So if I get an input like PST and DaylightSaving as true then I have to change the string as PDT.Whats even worse is sometimes I will get inputs like GMT-8 or GMT-6 with Day light flag as either true or false. Is there a way out ?
I can't use thirdparty TimeZone related classes
Code Sample:
TimeZone timeZone = TimeZone.getTimeZone("EST");
TimeZone timeZone = TimeZone.getTimeZone("PST");
TimeZone timeZone = TimeZone.getTimeZone("GMT-8");