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

The parse method in SimpleDateFormat causes a NullPointerException

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • None
    • unknown
    • core-libs
    • None
    • sparc
    • solaris_2.5.1

      User Name: David J. Miller
      Email: ###@###.###
      Platform: Solaris SPARC
      JWS Version: Java WorkShop 2.0 Pre-Beta
      Java Version: JDK1.1.1/jws:05/05/97
      Serial Number: JWS100-DAASSU-912858473

      I just downloaded build 93 and there appears to be a new bug in the
      SimpleDateFormat class' parse/subParse methods.
      I get a Null Pointer exception whenever I pass
      in a time string containing two zeros (00) in at least one of the time
      fields. If I replace the 00 with something else like 01, then it works.
      This problem did not exist in my previous version of Workshop.

      Here is a sample of the code, followed by the exception messages:

      private SimpleDateFormat timeFormatter;
      timeFormatter = new SimpleDateFormat("HH:mm:ss");
      timeFormatter.setLenient(false);

        public boolean correctTimeFormat(String timestring)
        {
          try
      {
      System.err.println(timestring);
      Date date = timeFormatter.parse(timestring);
      return true;
      }
          catch (ParseException parsee)
      {
      return false;
      }
        }
          
      10:03:07
      13:45:01
      13:50:00
      java.lang.NullPointerException
      at java.text.SimpleDateFormat.subParse(Compiled Code)
      at java.text.SimpleDateFormat.parse(Compiled Code)
      at java.text.DateFormat.parse(Compiled Code)
      at CPSupport.CPExecutionState.correctTimeFormat(Compiled Code)
      at Schedule.CPScheduleHandler.processHeaderDirectiveArgs(Compiled Code)
      at Schedule.CPScheduleHandler.processBeginops(Compiled Code)
      at Schedule.CPScheduleHandler.processDirective(Compiled Code)
      at Schedule.CPScheduleHandler.processSchedule(Compiled Code)
      at Schedule.CPScheduleHandler.<init>(Compiled Code)
      at CPThread.run(Compiled Code)

      ****

      This is reproducable.

      sfoster@eng 1997-05-29

            bcbeck Brian Beck (Inactive)
            sgfoster Stephen Foster (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: