Name: krC82822 Date: 10/01/2000
01 Oct 2000, eval1127@eng -- reproducible. See also # 4241052.
java version "1.2.2"
Classic VM (build JDK-1.2.2-W, native threads, symcjit)
(also happens with 1.2.2-001 and 1.3.0-C)
import java.text.*;
import java.util.*;
public class Numero {
public static void main(String[] args) {
NumberFormat nf = NumberFormat.getNumberInstance(new Locale("en", "US"));
try {
Number n = nf.parse("1 l");
System.out.println(n);
}
catch(Exception e) {
System.err.println("caught: " + e);
}
}
}
Output is
1
Note:
This should throw a FormatException unless maybe you were in France, which
should still throw an exception. Also the space in a French Locale is Unicode
160 and the space above is 32. I hope getParameter in servlets will give me a
160 groupseparator.
---------------------
(Review ID: 110129)
======================================================================
Name: yyT116575 Date: 02/07/2001
java version "1.3.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0_01)
Java HotSpot(TM) Client VM (build 1.3.0_01, mixed mode)
Set the NumberFormat locale to French. Then NumberFormat.parse() is not able to parse the breaking space that is sent when the input is, say, "2 2". The output of this parse is just 2. I guess the reason is that in the french
locale a non breaking space is the seperator. Still I think that a NumberFormat set to the french locale should be able to handle this.
NumberFormat numberFormat = NumberFormat.getInstance(Locale.FRENCH);
System.out.println(numberFormat.parse("9 000").intValue());
Output is 9, against the expected 9 000
(Review ID: 116527)
======================================================================
- duplicates
-
JDK-4241052 Semantics of Format.parseObject(String source) not well-defined
-
- Closed
-
-
JDK-4455064 NumberFormat doesn't parse currency numbers correctly
-
- Closed
-