~/ 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/e2581eb0-6bac-4452-bc1c-018638c166da/flashcard utf-8 LF