There are two types of spaces. โNormalโ space (No. 32 - HEX 0x20) and non-breaking space (NBSP) (No. 160 - HEX 0xA0).
For some reason (I donโt know why), the French locale expects the space character between numbers to be non-expanding space! You can help yourself with this line of code:
String num = "1 201"; num = num.replaceAll(" ", "\u00A0");
This way your code will work as expected. Please note: if you format double in String with French, the resulting space character will be NBSP too !!!
DecimalFormat df = (DecimalFormat) NumberFormat.getNumberInstance(Locale.FRENCH); System.out.println(df.format(1201.1));
source share