I have the below code:
DateFormat df = new SimpleDateFormat("M/d/yy h:mm a z");
df.setLenient(false);
System.out.println(df.parse("6/29/2012 5:15 PM IST"));
Assuming I now set my PC's timezone to Pacific Time (UTC-7 for PDT), this prints
Fri Jun 29 08:15:00 PDT 2012
Isn't PDT 12.5 hours behind IST (Indian Standard Time)? This problem does not occur for any other timezone - I tried UTC, PKT, MMT etc instead of IST in the date string. Are there two ISTs in Java by any chance?
P.S: The date string in the actual code comes from an external source, so I cannot use GMT offset or any other timezone format.
System.out.println(TimeZone.getTimeZone("IST").getRawOffset());This prints 19800000, or 5.5 hours, which suggests that it is indeed Indian Standard Time. Or is it picking up the first of many timezones with the same ID "IST"? If so, how can something be an "ID" if it is the same for many things? - VasanSimpleDateFormatis a strange beast, it's very likely that it isn't usingTimeZone.getTimeZone()at all. - biziclop