In this example, we’re formatting currencies based on US locale and Danish Locale.
Example
Open Compiler
importjava.text.NumberFormat;importjava.util.Locale;publicclassI18NTester{publicstaticvoidmain(String[] args){Locale enLocale =newLocale("en","US");Locale daLocale =newLocale("da","DK");NumberFormat numberFormat =NumberFormat.getCurrencyInstance(daLocale);System.out.println(numberFormat.format(100.76));
numberFormat =NumberFormat.getCurrencyInstance(enLocale);System.out.println(numberFormat.format(100.76));}}
Output
It will print the following result.
kr 100,76
$100.76
Leave a Reply