java.util.Currency.getDisplayName()
The method java.util.Currency.getDisplayName() gets the name that is suitable for displaying this currency for the default DISPLAY locale.
Method signature
The signature of the java.util.Currency.getDisplayName() method is as follows:
public String getDisplayName()
The method is available since Java 7.
Parameters
The method takes no parameters.
Return value
Returns the display name of this currency for the default DISPLAY locale.
Exceptions
The method throws no exceptions.
Example usage
In the following code we use java.util.Currency.getDisplayName():
package com.farenda.java.util; import java.util.Currency; import java.util.Locale; public class CurrencyGetDisplayName { public static void main(String[] args) { Currency currency = Currency.getInstance(Locale.CHINA); System.out.println("Currency: " + currency); System.out.println("Display name: " + currency.getDisplayName()); currency = Currency.getInstance(Locale.KOREA); System.out.println("Currency: " + currency); System.out.println("Display name: " + currency.getDisplayName()); } }
The above code produces the following output:
Currency: CNY Display name: Chinese Yuan Currency: KRW Display name: South Korean Won