1 Reply Latest reply: Nov 2, 2009 9:25 AM by 807580 RSS

    Can't get 01-NOV-2009 01:00 AM PDT from Calendar.

    807580
      Hi,

      I have my windows calendar timezone set to US/Pacific. When I try to set 01-NOV-2009 01:00 AM to the Calendar instance, it displays Sun Nov 01 01:00:00 PST 2009, although DST hasn't ended yet. It ends just after 01:59:59.9 on 01-NOV-2009. Why am I not getting the output as Sun Nov 01 01:00:00 PDT 2009?

      I am also trying to get the GMT offset at this time. I should be getting -420 mins instead of -480 mins.

      Here is my code snippet...

      Calendar cal = Calendar.getInstance();
      cal.set(2009, Calendar.NOVEMBER, 1, 1, 0, 0);
      System.out.println(cal.getTime());

      TimeZone tz = TimeZone.getTimeZone("US/Pacific");
      int offset = tz.getOffset(tmpCal.getTimeInMillis()) / 60000;
      System.out.println("Offset = " + offset);

      Please help.
        • 1. Re: Can't get 01-NOV-2009 01:00 AM PDT from Calendar.
          807580
          manorite wrote:
          Hi,

          I have my windows calendar timezone set to US/Pacific. When I try to set 01-NOV-2009 01:00 AM to the Calendar instance, it displays Sun Nov 01 01:00:00 PST 2009, although DST hasn't ended yet. It ends just after 01:59:59.9 on 01-NOV-2009. Why am I not getting the output as Sun Nov 01 01:00:00 PDT 2009?
          There are two 1 a.m.s, since we "fall backwards." 1 a.m. PST would be the same as 2 a.m. PDT on Nov 1.

          Edited by: endasil on 2-Nov-2009 10:25 AM