JDK-6771546 : [Fmt-De] Czech locales DecimalFormat grouping separator set to ascii code 160
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.text
  • Affected Version: 6u10
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2008-11-14
  • Updated: 2011-02-16
  • Resolved: 2010-11-19
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
build 1.6.0_10-b33

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP Professional Version 5.1.2600 Service Pack 3 Build 2600

A DESCRIPTION OF THE PROBLEM :
Czech locales DecimalFormat grouping separator is set to ascii code 160 instead of 32 or something else reasonable.
As an effect such formatted number cannot be parsed back.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
99(char 32)000
ACTUAL -
99(char 160)000

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.util.Locale;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.math.BigDecimal;

public class DecimalFormatTest {
	public static void main(String[] args) {
		Locale loc = new Locale("cs", "cz");
		DecimalFormat df = (DecimalFormat) NumberFormat.getInstance(loc);
		String str = df.format(new BigDecimal("99000"));
		System.out.println(str.indexOf(160) >= 0? "failed": "OK");
                // or format.parse(str) fails
	}
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
DecimalFormatSymbols dfs = df.getDecimalFormatSymbols();
dfs.setGroupingSeparator(' ');
df.setDecimalFormatSymbols(dfs);

Comments
PUBLIC COMMENTS I have a question to ask the submitter. In the submitter's program: Locale loc = new Locale("cs", "cz"); DecimalFormat df = (DecimalFormat) NumberFormat.getInstance(loc); String str = df.format(new BigDecimal("99000")); System.out.println(str.indexOf(160) >= 0? "failed": "OK"); // or format.parse(str) fails Does df.parse(str) (format.parse(str) doesn't seem to be collect) really fail and throw an exception ? If so, please send the stacktrace to us. I think the method should work correctly and return 99000. No-break space (0xA0) is used as a thousand separator for cs and some European locales. But it shouldn't make parse() fail for the text which was formatted with the same DecimalFormat instance. I know there's a different problem in DecimalFormat spec. Because DecimalFormat distinguishes the normal space (0x20) from No-break space, it cannot parse text in which 0x20 is used as a thousand separator. This often causes a problem when DecimalFormat is used to parse text which is typed in a text-input field of applications. If the submitter wanted to mean this problem, please update bug description of this bug report.
06-01-2009