FULL PRODUCT VERSION :
java version "1.8.0-ea"
Java(TM) SE Runtime Environment (build 1.8.0-ea-b124)
Java HotSpot(TM) Server VM (build 25.0-b66, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux ado-HP-625 3.8.0-35-generic #50-Ubuntu SMP Tue Dec 3 01:25:33 UTC 2013 i686 athlon i686 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
There's an unexpected space before the percentage sign if the locale is sv_SE. There's no space if the country is left out, though. The test case described below pretty much says it all.
REGRESSION. Last worked in version 8
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See test case described below.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
"78,93%"
"78,93%"
"78,93%"
ACTUAL -
"78,93 %"
"78,93%"
"78,93%"
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public static String getPercentage(Locale locale, int decimals, double value) {
//locale = new Locale(locale.getLanguage());
NumberFormat formatter = NumberFormat.getPercentInstance(locale);
formatter.setMinimumFractionDigits(decimals);
formatter.setMaximumFractionDigits(decimals);
return formatter.format(value);
}
assertEquals("78,93%", FormatterUtil.getPercentage(new Locale("sv", "SE"), 2, 0.7893));
assertEquals("78,93%", FormatterUtil.getPercentage(new Locale("sv"), 2, 0.7893));
assertEquals("78,93%", FormatterUtil.getPercentage(new Locale("sv", "FI"), 2, 0.7893));
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Uncomment the first line of getPercentage and the test case above will pass.