Microsoft SDK for Java

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

The information in this article applies to:

SYMPTOMS

When the parse method of the java.text.DateFormat cannot parse a date, the Microsoft VM 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 VM contained in the SDK for Java 3.0 and later.

MORE INFORMATION

To Reproduce Behavior

Create a Java project and include the following class:

   class Test
   {
      public static void main(String[] args)
      {

         {
            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 VM throws a NullPointerException instead of ParseException as mentioned in the Documentation.

REFERENCES

For the latest Knowledge Base articles and other support information on Microsoft® Visual J++® and the SDK for Java, please see the following pages on the Microsoft Technical Support site:

http://support.microsoft.com/support/visualj/ This link takes you to a site on microsoft.com

http://support.microsoft.com/support/java/ This link takes you to a site on microsoft.com

Additional query words:

DateFormat parse exception

© 1999 Microsoft Corporation. All rights reserved. Terms of use.