~/ learn/ java-from-zero/ cards/ Locale, NumberFormat & resource bundles
1 of 4

Type a currency format for a US locale

Type a currency format for a US locale

Answer

NumberFormat cf = NumberFormat.getCurrencyInstance(Locale.US); String s = cf.format(1999.99);

getCurrencyInstance creates a locale-aware formatter. In the US this produces "$1,999.99"; in Germany it produces "1.999,99 €".

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/bf4a596f-f0da-4a21-bcba-f2e1f61f1721/flashcard utf-8 LF