NumberFormat and locale
import java.text.NumberFormat;
import java.util.Locale;
public class Main {
public static void main(String[] args) {
double value = 1234567.89;
System.out.println("Unformatted: " + value + "\n");
Locale locales[] = { Locale.US, Locale.FRANCE, Locale.GERMANY, Locale.JAPAN,
new Locale("fr", "FR", "EURO"), new Locale("de", "DE", "EURO") };
for (int i = 0; i < locales.length; i++) {
NumberFormat nf = NumberFormat.getCurrencyInstance(locales[i]);
System.out.println("Formatted for " + locales[i] + ": " + nf.format(value));
}
}
}
Related examples in the same category