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

API: SimpleDateFormat throws NullPointerException when parsing with null pattern

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 1.4.0
    • 1.3.0
    • core-libs
    • beta2
    • generic
    • generic



      Name: stC104175 Date: 03/31/2000


      java version "1.3beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build
      Java(TM) HotSpot Client VM (build 1.3beta-O, mixed mode)



      1) Just run and see.

      2) a test source....

      import java.text.*;

      public class SDFTest
      {

      public static void main (String[] args)
      {
      String dateFormat = null;
      try
      {
      // Note: the dateFormat is a 'null'.
      // This -was- becourse it should come from a database
      // and returnd a null object.
      // The workaround is just build in the -normal- null
      check.
      SimpleDateFormat df = new SimpleDateFormat (dateFormat);
      df.parse("01-01-2000");
      }
      catch (ParseException e)
      {
      System.out.println ("[SDFTest] Unparsable date");
      }
      catch (Exception e)
      {
      System.out.println ("[SDFTest] Another Exception.");
      e.printStackTrace();
      }
      }
      }

      3) The error message:

      c:\java\jdk1.3\bin\java.exe SDFTest
      [SDFTest] Another Exception.
      java.lang.NullPointerException
      at java.text.SimpleDateFormat.parse(SimpleDateFormat.java:640)
      at java.text.DateFormat.parse(DateFormat.java:329)
      at SDFTest.main(SDFTest.java:16)

      4) Info:
      This is not only -not- working on 1.3 but also on 1.1.8 and 1.2.2

      5) Configuration...
      On different windows (nt4) configurations this will get a nullpointer...
      (Review ID: 103143)
      ======================================================================

            okutsu Masayoshi Okutsu
            stompkinsunw Sean Tompkins (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: