I tried to parse a string (14 123) to a long in java using Swedish locale using this code:
String longString = "14 123"
NumberFormat swedishNumberFormat = NumberFormat.getInstance(new Locale("sv"));
System.out.println(swedishNumberFormat.parse(longString).longValue());
The output of this code is 14 (it should be 14123). As per this question I tried with both the sv and sv_SE locale but this time the result was identical in both cases.
According to http://www.localeplanet.com/java/sv/index.html and http://www.localeplanet.com/java/sv-SE/index.html the grouping separator in both cases is a space() so why does the string to long parsing not handle a, for the locale, properly formatted double value stored as string?
Swedish, as French too, needs a hard. non-breaking space.
longString = longString.replace(' ', '\u00a0');
Cumbersome.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With