Building TimeZone object in Java
Posted
by
Harish
on Stack Overflow
See other posts from Stack Overflow
or by Harish
Published on 2010-12-22T05:07:51Z
Indexed on
2010/12/22
5:54 UTC
Read the original article
Hit count: 616
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");
© Stack Overflow or respective owner