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

Doc: java.util.SimpleTimeZone class javadoc contradict itself and implementation

XMLWordPrintable

    • b32
    • x86, sparc
    • solaris_2.6, windows_2000, windows_xp
    • Verified



      Name: aaR10142 Date: 11/25/2003


      Filed By : SPB JCK team (###@###.###)
      JDK : java full version "1.5.0-beta-b28"
      JCK : 1.5
      Platform[s] : Solaris
      switch/Mode :
      JCK test owner : http://javaweb.eng/jct/sqe/JCK-tck/usr/owners.jto
      Failing Test [s] : N/A


      Problem description
      ===================
      To set Day of week on or after day of month,
      the spec require use "SUNDAY", but it does not work See Test.java.

      The javadoc example in the use "-SUNDAY", and it works

      So please remove this contradiction and specify correct behavior.

          
      Specification excerpt:
      ======================
      --------- J2SE API spec v.1.5 ---------
      ...
      Day of week on or after day of month
      To specify a day of week on or after an exact day of month, set the month to
      an exact month value, day-of-month to the day on or after which the rule is
      applied, and day-of-week to a DAY_OF_WEEK field value. For example, to specify
       the second Sunday of April, set month to APRIL, day-of-month to 8, and
      day-of-week to SUNDAY.
      !!!! ^^^^^^^^^^^

      Example:
          // Base GMT offset: -8:00
            // DST starts: at 2:00am in standard time
            // on the first Sunday in April
            // DST ends: at 2:00am in daylight time
            // on the last Sunday in October
            // Save: 1 hour
            SimpleTimeZone(-28800000,
                           "America/Los_Angeles",
                           Calendar.APRIL, 1, -Calendar.SUNDAY,
       !!!!!!!! ^^^^^^^^
                          7200000,
                           Calendar.OCTOBER, -1, Calendar.SUNDAY,
                           7200000,
                           3600000)
      ...
      ---------- end-of-excerpt ---------------

      Minimized test:
      ===============
      ------- Test.java -------
      import java.util.*;

      public class Test {
                                                                     
          public static void main(String argv[]) {
              SimpleTimeZone stz = new SimpleTimeZone(
                    320000, "stz",
                    0, 15, 1, 0,
                    6, 15, 1, 0,
                    1
                  );

          }
      }

      ------- end-of-Test.java -------

      Minimized test output:
      ======================
      Exception in thread "main" java.lang.IllegalArgumentException: Illegal start day of week in month 15
              at java.util.SimpleTimeZone.decodeStartRule(SimpleTimeZone.java:1383)
              at java.util.SimpleTimeZone.decodeRules(SimpleTimeZone.java:1323)
              at java.util.SimpleTimeZone.<init>(SimpleTimeZone.java:333)
              at java.util.SimpleTimeZone.<init>(SimpleTimeZone.java:260)
              at Test.main(Test.java:6)



      ======================================================================

            okutsu Masayoshi Okutsu
            alisunw Ali Ali (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: