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

parsing 1/1/00 gives back 1900

XMLWordPrintable

    • 1.1.6
    • sparc
    • solaris_2.4, solaris_2.5.1
    • Verified

        Received from jdk-comments:

        Date: Wed, 20 Aug 1997 13:34:16 -0600
        From: Jack Barnard <###@###.###>
        Organization: Lucent Technologies
        X-Mailer: Mozilla 4.01 [en] (WinNT; I)
        To: ###@###.###
        Subject: Year 2000 (Y2K) problem
        X-Priority: 3 (Normal)

        Hi,

        The SimpleDateFormat in JDK1.1 does not support year 2000.
        When I enter 1/1/00 it gives me 01-Jan-1900 back!
        --

        Jack Barnard
        Lucent Technologies
        Distinguished MTS
        ###@###.###
        (303)538-3976

        this seemed a little odd but the following program exhibits the
        behaviour:

        class dateyy {
                public static void main(String[] args) {
                        SimpleDateFormat formatter = new SimpleDateFormat ("yy.mm.dd");
                     
        ParsePosition pos = new ParsePosition(0);
                        Date currentTime_2 = formatter.parse("00.1.1", pos);

                        formatter = new SimpleDateFormat ("yyyy.mm.dd");
                        String datestring = formatter.format(currentTime_2);

                        System.out.println(datestring);
                }
        }

        which gives

        1900.1.1

        maybe it shouldn't default to 1900 but give back 0000.1.1 I don't
        know what this would break.

        The provided testcase is not completed. Missing import statement. Need to addimport java.text.*; verify at jdk116e, fixed

              joconnersunw John Oconner (Inactive)
              rcalnan Roger Calnan
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: