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

Can set GregorianCalendar to time that doesn't exist for 2038+ in EST5EDT

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 7u51
    • core-libs

      FULL PRODUCT VERSION :
      java 1.7.0_51

      ADDITIONAL OS VERSION INFORMATION :
      Mac OSX 10.9
      Darwin my-hostname 13.3.0 Darwin Kernel Version 13.3.0: Tue Jun 3 21:27:35 PDT 2014; root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64

      A DESCRIPTION OF THE PROBLEM :
      Calendar does not change to an hour ahead after setting calendar to a spring forward hour on a spring forward day past 2037. (2-2:59am a time that does not exist)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
          Calendar cal = new GregorianCalendar();
          TimeZone zone = TimeZone.getTimeZone("EST5EDT");
          cal.setTimeZone(zone);
          cal.set(2037, 2, 8, 2, 30, 0);
          int hour = cal.get(Calendar.HOUR_OF_DAY);
          int minute = cal.get(Calendar.MINUTE);
          cal.set(2038, 2, 14, 2, 30, 0);
          hour = cal.get(Calendar.HOUR_OF_DAY);
          minute = cal.get(Calendar.MINUTE);

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      hour and minute should be 3:30 when setting cal to 3/14/2038 2:30 (2:30 does not exist on this date)
      ACTUAL -
      Hour and minute = 2:30, a time that does not exist on this date.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      Calendar cal = new GregorianCalendar();
          TimeZone zone = TimeZone.getTimeZone("EST5EDT");
          cal.setTimeZone(zone);
          cal.set(2037, 2, 8, 2, 30, 0);
          int hour = cal.get(Calendar.HOUR_OF_DAY);
          int minute = cal.get(Calendar.MINUTE);
          cal.set(2038, 2, 14, 2, 30, 0);
          hour = cal.get(Calendar.HOUR_OF_DAY);
          minute = cal.get(Calendar.MINUTE);
      ---------- END SOURCE ----------

            naoto Naoto Sato
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: