As we have internationalize the date, time and numbers, we can internationalize the currency also. The currency differs from one country to another so we need to internationalize the currency.
The NumberFormat class provides methods to format the currency according to the locale. The getCurrencyInstance() method of the NumberFormat class returns the instance of the NumberFormat class.
The syntax of the getCurrencyInstance() method is given below:
public static NumberFormat getCurrencyInstance(Locale locale)
In this example, we are internationalizing the currency. The format method of the NumberFormat class formats the double value into the locale specific currency.
import java.text.NumberFormat; import java.util.*; public class InternalizationCurrency { static void printCurrency(Locale locale){ double dbl=10500.3245; NumberFormat formatter=NumberFormat.getCurrencyInstance(locale); String currency=formatter.format(dbl); System.out.println(currency+" for the locale "+locale); } public static void main(String[] args) { printCurrency(Locale.UK); printCurrency(Locale.US); printCurrency(Locale.FRANCE); } }