I am using this code to parse this date. It must show new date as "2012-06-20 03:09:38" as EDT is -4GMT and my current location is GMT+5. But its not showing this it now showing as it is
private static void convertEDT_TO_GMT() {
try {
String s = "2012-06-20 18:09:38";
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
df.setTimeZone(TimeZone.getTimeZone("EDT"));
Date timestamp = null;
timestamp = df.parse(s);
df.setTimeZone(TimeZone.getTimeZone("GMT+05:00"));
System.out.println("Old = " + s);
String parsed = df.format(timestamp);
System.out.println("New = " + parsed);
} catch (Exception e) {
e.printStackTrace();
}
}
It show
Old = 2012-06-20 18:09:38
New = 2012-06-20 23:09:38
The time zone ‘EDT’ does not exist. Doing a
System.out.println()of `TimeZone.getTimeZone(“EDT”) shows that it is falling back to GMT because Java does not know ‘EDT’ as a time zone.Changing from
"EDT"to"GMT-04:00"gives the correct result:Result:
According to this post:
So using
"GMT-04:00"might be the right solution.