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

Calendar.getInstance() gives incorrect time on Asia/Irkutsk, summer time

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 5.0
    • core-libs

      FULL PRODUCT VERSION :
      java version "1.5.0_03"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
      Java HotSpot(TM) Client VM (build 1.5.0_03-b07, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Windows XP Service Pack 2

      A DESCRIPTION OF THE PROBLEM :
      Java determinates incorrect time zone in Asia/Irkutsk. Java supposes that it is Asia/Ulaanbaatar. Asia/Irkutsk use winter/summer time, Asia/Ulaanbaatar not. So, System.out.println(Calendar.getInstance().getTime()); prints wrong time when there is a summer time in Asia/Irkutsk. It prints one hour earlier time.
      For example, it prints Sat May 07 09:53:12 ULAT 2005 when time is 10:53.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Set computer locale GMT+8, Ulaanbaatar/Irkutsk, use summer time; and date, when summer time is used, for example now (7th May) in Windows Control Panel. Execute System.out.println(Calendar.getInstance().getTime()); . It will print wrong time.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Valid system time.
      ACTUAL -
      Wrong system time.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.util.Calendar;

      public class Test {

      public static void main(String[] args) {
      System.out.println(Calendar.getInstance().getTime());
      }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Set time zone to Asia/Irkutsk manually on program start. But it is not a good solution.
      ###@###.### 2005-05-24 11:57:10 GMT

            okutsu Masayoshi Okutsu
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: