java.util.Currency.getDisplayName(Locale)
The method java.util.Currency.getDisplayName(Locale) gets the name that is suitable for displaying this currency for the specified locale.
Method signature
The signature of the java.util.Currency.getDisplayName(Locale) method is as follows:
public String getDisplayName(Locale locale)
The method is available since Java 7.
Parameters
- Locale: the locale for which a display name for this currency is needed
Return value
Returns the display name of this currency for the specified locale.
Exceptions
- NullPointerException: if locale is null
Example usage
In the following code we use java.util.Currency.getDisplayName(Locale):
package com.farenda.java.util; import java.util.Currency; import java.util.Locale; public class CurrencyGetDisplayNameWithLocale { public static void main(String[] args) { Currency currency = Currency.getInstance(Locale.CHINA); System.out.println("Currency: " + currency); System.out.println("French display name: " + currency.getDisplayName(Locale.FRANCE)); System.out.println("Korean display name: " + currency.getDisplayName(Locale.KOREA)); } }
The above code produces the following output:
Currency: CNY French display name: yuan renminbi chinois Korean display name: 중국 위안 인민폐