FIX: java.text.DateFormat.parse() Throws a NullPointerException (177751)



The information in this article applies to:

  • Microsoft SDK for Java 2.0
  • Microsoft Internet Explorer 4.01 for Windows NT 4.0, when used with:
    • the operating system: Microsoft Windows NT
    • the operating system: Microsoft Windows 95
  • Microsoft virtual machine

This article was previously published under Q177751

SYMPTOMS

When the parse() method of the java.text.DateFormat cannot parse a date, the Microsoft virtual machine incorrectly throws a NullPointerException error instead of a ParseException error.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
This bug was corrected in the Microsoft virtual machine contained in the SDK for Java 3.0 and later.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a Java project and include the following class:
    class Test
    {
       public static void main(String[] args)
       {
          try
          {
             java.text.DateFormat Df;
             Df = java.text.DateFormat.getDateInstance();
             Df.parse("Foo");
             System.out.println ("Done.");
          }
          catch(Exception e)
    
          {
             System.err.println("caught exception");
             e.printStackTrace();
          }
       }
    }
    						
java.text.DateFormat is a package that is included with JDK1.1. Build the above code with the JVC that is provided in the SDK2.0x for Java and execute. You will see that the Microsoft virtual machine throws a NullPointerException instead of ParseException as mentioned in the Documentation.

REFERENCES

For support information about Visual J++ and the SDK for Java, visit the following Microsoft Web site:

Modification Type:MajorLast Reviewed:6/14/2006
Keywords:kbbug kbfix kbSDKJava300fix kbSDKJava310fix KB177751