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

java.util.Date constructor throws IllegalArgumentException

    XMLWordPrintable

Details

    • 1.1
    • sparc
    • solaris_2.5
    • Not verified

    Description

      === Here is the test demonstrating the bug ===
      import java.util.Date;
      class java_util_Date2 {
        public static void main (String args[]) {
          Date d=new java.util.Date(96,30,1,22,15,5);
          System.out.println(d);

        }
      }

      === Here is the test output ===
      java.lang.IllegalArgumentException
      at java.util.GregorianCalendar.computeTime(GregorianCalendar.java)
      at java.util.Date.getTime(Date.java)
      at java.util.Date.toString(Date.java)
      at java.io.PrintStream.print(PrintStream.java)
      at java.io.PrintStream.println(PrintStream.java)
      at java_util_Date2.main(java_util_Date2.java:5)

      === Here is the part of Java Language Specification (Item 21.3) ===
      A month is represented by an integer form 0 to 11; 0 is
      January, 1 is February, and so on; thus 11 is December.

      [skip]
       
      In all cases, arguments given to methods for these purposes
      need not fall within the indicated ranges; for example, a date
      may be specified as January 32 and will be interpreted as
      meaning February 1.

      Attachments

        Activity

          People

            duke J. Duke
            mgorshen Mikhail Gorshenev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: