Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6961979

GregorianCalendar returns wrong Time and TimeZone.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 6u10
    • core-libs

      FULL PRODUCT VERSION :
      java version "1.6.0_20"
      Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
      Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 5.2.3790]

      A DESCRIPTION OF THE PROBLEM :
      I am using GregorianCalendar class to get current time.

      GregorianCalendar today = new GregorianCalendar();
      Date currenttime = today.getTime();

      If i print "currenttime ", it is printing wrong time.

      Current system time is 19:00, but it is giving 08:30 VET
      The time zone of my system is "GMT+6:00 Dhaka".

      Previously my system time zone was "GMT-6:00 Central Time (US & Canada)" and "Automatically adjust clock for daylight saving changes" is checked.
      Here everything is fine.

      Only after changing this time zone to "GMT+6:00 Dhaka", I am facing this issue.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Set the system time zone to "GMT-6:00 Central Time (US & Canada)" and check "Automatically adjust clock for daylight saving changes". Click Apply
      2. Now change the time zone to "GMT+6:00 Dhaka". and click apply.

      Now using the below api, print the current time.

      GregorianCalendar today = new GregorianCalendar();
      Date currenttime = today.getTime();


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Thu Jun 16 19:15:20 GMT+6:00 2010

      ACTUAL -
      Thu Jun 16 08:45:20 VET 2010

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      GregorianCalendar today = new GregorianCalendar();
      Date currenttime = today.getTime();

      System.out.println("Current time is = "+currenttime );
      ---------- END SOURCE ----------

            okutsu Masayoshi Okutsu
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: