-
Bug
-
Resolution: Fixed
-
P3
-
1.1.4, 1.2.0
-
1.2beta4
-
generic, sparc
-
generic, solaris_2.5
-
Verified
Name: dfC67450 Date: 01/26/98
java.text.DecimalFormat.parse(String str, ParsePosition pp) returns 0 if string
parameter is incorrect. For consistency with previous JDK version it should return
null.
Here is the test demonstrating the bug:
-----------------Test.java------------------------
import java.text.*;
public class Test {
public static void main (String args[]){
DecimalFormat df = new DecimalFormat();
String text = "x";
System.out.println("pattern: \"" + df.toPattern() + "\"");
System.out.println("\"" + text + "\" is parsed as " +
df.parse(text, new ParsePosition(0)));
}
}
--------- Output from the test for JDK1.1.6 ---------------------
pattern: "#,##0.###"
"x" is parsed as 0
--------- Output from the test for JDK1.1.5 ---------------------
pattern: "#,##0.###"
"x" is parsed as null
--------------------------------------------------
======================================================================
- duplicates
-
JDK-4104136 java.text.SimpleDateFormat.parse() incorrectly sets ParsePosition index
- Closed
-
JDK-4114639 NumberFormat.parse doesn't return null
- Closed