-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
1.2.0
-
sparc
-
solaris_2.5
Name: dfC67450 Date: 05/28/98
java.text.DecimalFormat.parse(String str, ParsePosition pp) parses
wrong if zeroDigit field of DecimalFormatSymbols field is not set to 0.
It uses two sets of digit representation:
'0'..'9' and zeroDigit .. zeroDigit + 9.
Here is the test demonstrating the bug:
-----------------TestPZ.java------------------------
import java.text.*;
import java.util.*;
public class Test {
public static void main (String args[]){
DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.ENGLISH);
dfs.setZeroDigit('n');
DecimalFormat df = new DecimalFormat("#,##0", dfs);
String formatted123 = df.format(123);
String text123123 = formatted123 + "123";
Number parsed = df.parse(text123123, new ParsePosition(0));
System.out.println("zeroDigit: " + dfs.getZeroDigit());
System.out.println("format(123): " + formatted123);
System.out.println("parse(" + text123123 +") : " + parsed);
if (parsed != null) {
System.out.println("test failed, parse should return null");
} else {
System.out.println("test passed");
}
}
}
---------Output from the test---------------------
zeroDigit: n
format(123): opq
parse(opq123) : 123123
test failed, parse should return null
--------------------------------------------------
======================================================================