locale and decimalFormat confusion
I'm a bit confused about DecimalFormat. It seems that even if I specify a format string for DecimalFormat, the decimal separator in the string is ignored if I change the locale. What I want is to always format 1.0 as "1.00" regardless of whether the locale is en or fr.
Here is some short code:
Code:
Locale L = Locale.getDefault();
System.out.println(L.getLanguage());
NumberFormat nf = new DecimalFormat("#,##0.00");
System.out.println(nf.format(1.0));
L = new Locale("fr");
Locale.setDefault(L);
System.out.println(L.getLanguage());
nf = new DecimalFormat("#,##0.00");
System.out.println(nf.format(1.0));
the output is:
What can I do to always get "1.00" even when the locale is fr?
Thanks!