I have a Java Date
that is from this summer during daylight savings time. For example:
Jun 01, 2009 06:00 AM PDT
My question is, how do I display this date as my local time zone and current daylight savings mode (in my case Pacific Standard Time)?
Jun 01, 2009 05:00 AM PST
Java's Date.toString()
and SimpleDateFormat
displays the date in the original daylight savings mode. Example:
System.out.println(new Date(1243861200000L));
outputs:
Mon Jun 01 06:00:00 PDT 2009
DateFormat dateFormat = new SimpleDateFormat("MMM dd, yyyy hh:mm aa zzz");
dateFormat.setTimeZone(TimeZone.getTimeZone("PST"));
System.out.println(dateFormat.format(new Date(1243861200000L)));
outputs:
Jun 01, 2009 06:00 AM PDT
What I really want to see is 5:00 AM PST (which is equivalent to 6:00 AM PDT). Is there a way to force it to use another daylight savings mode?
Follow up: By the way, this is the Windows XP behavior. A file created on June 1, 6 AM will be seen (by Explorer, Command Prompt, etc) as June 1, 5 AM during the winter.