-
Bug
-
Resolution: Fixed
-
P4
-
11, 13, 14
-
b23
-
x86_64
-
windows_10
A DESCRIPTION OF THE PROBLEM :
Since we are using the locale provider "HOST" (setting the system property "java.locale.providers"), we do have a problem with "MessageFormat.format()" when passing integer (or long) values as parameters.
Running the program on a windows client (Windows 10 with german locale) formats the integer with 2 decimal places, e.g. "10,00" for integer "10".
So MessageFormat.format("Page {0} of {1}", 12, 100); produces "Page 12,00 of 100,00" instead of "Page 12 of 100".
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the java main (source code see below) under a windows 10 client.
Debugging the code shows the following:
The MessageFormat.format() uses NumberFormat.getInstance(locale) to create a format for numbers - for all kinds of numbers (double, integer, ...). NumberFormat call the getNumberInstance method of the locale provider. The HostLocaleProviderAdapterImpl returns a format with "#,##0.00;-#,##0.00" as pattern which is the reason for the unnecessary two digital places.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
With german windows 10 locale:
Page 12 of 100
ACTUAL -
With german windows 10 locale:
Page 12,00 of 100,00
---------- BEGIN SOURCE ----------
import java.text.MessageFormat;
public class Main {
public static void main(String[] args) {
System.setProperty("java.locale.providers", "HOST,COMPAT,SPI");
System.out.println(MessageFormat.format("Page {0} of {1}", 12, 100));
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Formatting the integer as a string and pass this string as a parameter is a workaround for a direct call of MessageFormat.format() in our code, but doesn't help if e.g. a lib uses MessageFormat.format() with integer values.
FREQUENCY : always
Since we are using the locale provider "HOST" (setting the system property "java.locale.providers"), we do have a problem with "MessageFormat.format()" when passing integer (or long) values as parameters.
Running the program on a windows client (Windows 10 with german locale) formats the integer with 2 decimal places, e.g. "10,00" for integer "10".
So MessageFormat.format("Page {0} of {1}", 12, 100); produces "Page 12,00 of 100,00" instead of "Page 12 of 100".
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the java main (source code see below) under a windows 10 client.
Debugging the code shows the following:
The MessageFormat.format() uses NumberFormat.getInstance(locale) to create a format for numbers - for all kinds of numbers (double, integer, ...). NumberFormat call the getNumberInstance method of the locale provider. The HostLocaleProviderAdapterImpl returns a format with "#,##0.00;-#,##0.00" as pattern which is the reason for the unnecessary two digital places.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
With german windows 10 locale:
Page 12 of 100
ACTUAL -
With german windows 10 locale:
Page 12,00 of 100,00
---------- BEGIN SOURCE ----------
import java.text.MessageFormat;
public class Main {
public static void main(String[] args) {
System.setProperty("java.locale.providers", "HOST,COMPAT,SPI");
System.out.println(MessageFormat.format("Page {0} of {1}", 12, 100));
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Formatting the integer as a string and pass this string as a parameter is a workaround for a direct call of MessageFormat.format() in our code, but doesn't help if e.g. a lib uses MessageFormat.format() with integer values.
FREQUENCY : always
- relates to
-
JDK-8236495 open/test/jdk/java/util/Locale/LocaleProvidersRun.java failed on mac 10.14 with de_DE locale.
- Resolved
-
JDK-8243646 SimpleDateFormat fails parsing Date if decimal date separators are used
- Closed