Daylight Savings problem using GMT-5
Hi All,
How to retreive the time for the GMT-5 timezone with the DST applied. Below is the sample code to convert the date to a specific timezone.
SimpleDateFormat sdf = null;
Date date = null;
sdf = new SimpleDateFormat("M/d/y h:m:s a");
date = sdf.parse("5/1/2007 10:30:00 AM");
System.out.print("5/1/2007 10:30:00 AM ====== "+getGMTOffset("GMT-5", date.getTime()));
Above code does not retreive the time as per the DST. I'm using JDK 1.4.2_13 (DST patch) JDK version. Any code with the GMT time zone is not converted to the DST. If I use the EST or America/New_York in place of GMT-5 the time is correct as per DST.
Since GMT-5 is same as EST I should be able to use any of the values.
Thanks in advance
AV.
# 2
Thank you for the information.
I did check the below code for both daylight savings (DST) and non-DST dates
SimpleDateFormat sdf = null;
Date date = null;
sdf = new SimpleDateFormat("M/d/y h:m:s a");
date = sdf.parse("3/1/2007 10:30:00 AM");
System.out.print("3/1/2007 10:30:00 AM ====== "+getGMTOffset("EST", date.getTime()));
output is -18000000
date = sdf.parse("3/15/2007 10:30:00 AM");
System.out.print("3/15/2007 10:30:00 AM ====== "+getGMTOffset("EST",
output is -14400000
The output is different for 3/1 vs 3/15 as the DST starts from 3/11.
I executed the same code for time zone GMT-5 on 3/1 and 3/15 the output remains same. They do not change even the DST starts on 3/11 for the GMT-5 timezone.
Could this say that the GMT-5 is not effected by DST.
In my application I need to handle the Daylight Savings for GMT-5 as it is handled default by the JRE.
Thanks
AV