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

Out of bounds exception thrown from SimpleDateFormat

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.1.6
    • core-libs
    • x86
    • windows_nt



      Name: mf23781 Date: 08/03/98


      Run the code below and you will see the following exception
      thrown:

      java.lang.StringIndexOutOfBoundsException: String index out of
          range: 25

      //Test Case DateTest.java

      import java.text.*;

      class DateTest
      {
      public static void main(String args[])
      {
      SimpleDateFormat dateFormatter = new SimpleDateFormat("MM/dd/yy HH:mm:ss.SSS zzz");
      try
      {
      dateFormatter.parse("12/31/97 12:00:00.000 GMT");
      }
      catch(Exception e)
      {
      System.out.println("Exception: " + e);
      }
      }
      }

      If you add a space after GMT then no exception is thrown!

      This appears to be fixed in 1.2beta4 FCS, but ideally should be fixed in the 1.1.x line.
      ======================================================================

            aliusunw Alan Liu (Inactive)
            miflemi Mick Fleming
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: