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

ID: Q177751


The information in this article applies to:


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 this to be a bug in the Microsoft products 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 the latest Knowledge Base articles and other support information on Visual J++ and the SDK for Java, please see the following pages on the Microsoft Technical Support site:

http://support.microsoft.com/support/visualj/

http://support.microsoft.com/support/java/

Additional query words: DateFormat parse exception


Keywords          : kbSDKJava300fix JVM kbSDKJava310fix 
Version           : WINDOWS:2.0,4.0
Platform          : WINDOWS 
Issue type        : kbbug 

Last Reviewed: July 26, 1999