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

jdk 1.0.2 , Date class has limited year range

XMLWordPrintable

    • 1.1
    • generic
    • solaris_2.5.1
    • Verified

      java.util.Date is limited to the year range (1970 - 2037) and this is inconvenient when working with historic data, birthdates, etc. A runtime exception of java.lang.IllegalArgumentException: year out of range is thrown when an incorrect year is used.

      Here is a test case :

      import java.util.*;

       
      public class DateTest
      {
       
        public static void main (String[] args)
        {
          // set the year at 2038
          Date mybd = new Date(138, 10, 15);

          System.out.println("Year : " + mybd.getYear());
          System.out.println("Month : " + mybd.getMonth());
          System.out.println("Day : " + mybd.getDay());

          System.exit(0);

        }
      }

            duke J. Duke
            gvanassesunw Gunter Vanasse (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: