Példa

public static void main( String[] args ){
double value = 12345.678;
Locale defaultLocale = Locale.getDefault();
NumberFormat nf = NumberFormat.getCurrencyInstance(defaultLocale);
String formattedValue = nf.format(value);
System.out.println(formattedValue);
}
Megoldás
Használj a com.ibm.icu.util.Currency (ICU 2.6.1) vagy a java.util.Currency metódust
  1. Hívja meg a következőt
    Currency.getInstance (java.lang.String)
  2. Hívja meg a következőt
    java.text.NumberFormat.setCurrency (java.util.Locale)

public static void main( String[] args ){
double value = 12345.678;
Currency currency = Currency.getInstance("EUR"); //$NON-NLS-1$
Locale defaultLocale = Locale.getDefault();
NumberFormat nf = NumberFormat.getCurrencyInstance(defaultLocale);
nf.setCurrency(currency);
String formattedValue = nf.format(value);
System.out.println(formattedValue);
}