java.util.Currency getDisplayName()


The getDisplayName() method of Currency class is use to get the name that is suitable for displaying this currency for the default DISPLAY locale. If there is no suitable display name found for the default locale, the ISO 4217 currency code is returned. This method returns a more sensible value of the currency object like for instance a currency code of NZD, it doesn’t make much sense to display this value but rather its much better to use the getDisplayName which returns New Zealand Dollar for user consumption.

Method Syntax

public String getDisplayName()

Method Argument

Data Type Parameter Description

Method Returns

The getDisplayName() method of Currency class returns the display name of this currency for the default DISPLAY locale.


Java 1.7

Java Currency getCurrencyCode() Example

Below is a simple java example on the usage of getDisplayName() method of Currency class.


import static java.lang.System.*;

import java.util.Currency;

 * This example source code demonstrates the use of 
 * getDisplayName() method of Currency class.

public class CurrencyGetDisplayNameExample {

	public static void main(String[] args) {	
		// create an instance of Currency class
		Currency currency = Currency.getInstance("NZD");
		// prints a more sensible value for currency NZD
		out.println("NZD is equal to "+currency.getDisplayName());		

Basically on the above example, we just created a new Currency object with currency code of NZD. Then we use the getDisplayName() toa value that is more user friendly.

Sample Output

Below is the sample output when you run the above example.

Currency getDisplayName() Sample Output