Microsoft KB Archive/177751

= FIX: java.text.DateFormat.parse Throws a NullPointerException =

Article ID: 177751

Article Last Modified on 6/14/2006

-

APPLIES TO

 Microsoft Software Development Kit for Java 2.02 Microsoft Internet Explorer 4.01 128-Bit Edition, when used with:  Microsoft Windows NT 4.0

 Microsoft Windows 95  Microsoft Java Virtual Machine

-

<div class="notice_section">

This article was previously published under Q177751

<div class="symptoms_section">

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.

<div class="status_section">

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.

<div class="moreinformation_section">

Steps to Reproduce Behavior
<ol>  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; }  } }                        </li></ol>

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.

<div class="references_section">