Name: yyT116575 Date: 10/03/2001
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
This is an attempt to reopen bug 4350931.
That bug complained that the French thousands separator
(when formatting numbers) does not print. The bug was
closed; it was claimed that the thousands separator is a space.
It is true that the separator is a space, but it is a special non-breaking
space -- the character 0xA0. This means that if the user in a UI types
a number with (normal) spaces, the Java formatting code will reject it
with an error.
It's not even clear that this special space character will be displayed
as such in a HTML client. Certainly it will not occur to a user who
sees an existing value that he needs to type a funny space character.
The following source code shown the spaces will cause the number
be rejected.
import java.text.*;
import java.util.Locale;
public class French {
public static void main(String args []) {
NumberFormat form = NumberFormat.getInstance(Locale.FRENCH);
form.setGroupingUsed(true);
String fmt = form.format(123456.789);
System.out.println("Here is the formatted value:");
for (int i = 0; i < fmt.length(); i++) {
System.out.print((int) (fmt.charAt(i)));
System.out.println(" " + fmt.charAt(i));
}
String fmtAsSpace = "123 456,789";
System.out.println("About to parse " + fmtAsSpace);
try {
System.out.println(form.format(fmtAsSpace));
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}
Here is the output:
Here is the formatted value:
49 1
50 2
51 3
160 ?
52 4
53 5
54 6
44 ,
55 7
56 8
57 9
About to parse 123 456,789
Cannot format given Object as a Number
(Review ID: 132812)
======================================================================
- duplicates
-
JDK-8190914 Unable to implement workaround to JDK-4510618 bug with java 9 => Unable to parse french numbers
-
- Closed
-
-
JDK-6318800 parse() method of NumberFormat does not parse for French Locale
-
- Closed
-
-
JDK-6771546 [Fmt-De] Czech locales DecimalFormat grouping separator set to ascii code 160
-
- Closed
-
-
JDK-8167174 Parsing a string to a double in Finnish throws exception. Java is not respecting the Locale
-
- Closed
-
- relates to
-
JDK-8185849 NumberFormat.getPercentInstance().parse(String) does not work in Java 9
-
- Closed
-
-
JDK-4350931 Thousands separator not displayable for Locale.FRENCH
-
- Closed
-