Java Currency getDisplayName() Method

There are two types of getDisplayName methods.

Java Currency getDisplayName() Method

The getDisplayName() is the method of Java Currency class which is used to get the name of invoking currency for the default locale.

Syntax

Following is the declaration of getDisplayName() method:

Parameter

DataTypeParameterDescription
NANAThis method does not accept any parameter.

Returns

The getDisplayName() method is used to get the name of invoking currency for the default locale.

Exceptions

NA

Compatibility Version

Java 1.7 and above

Example 1

Output:

INR is: Indian Rupee

Example 2

Output:

Currency: USD
Display name: US Dollar
Currency: CNY
Display name: Chinese Yuan

Example 3

Output:

Name of given Currency is: Euro

Example 4

Output:

Enter the Currency: INR
Currency name is: Indian Rupee

Java Currency getDisplayName(Locale locale) Method

The getDisplayName(Locale locale) is the method of Java Currency class is used to get the name of invoking currency for the specified locale.

Syntax

Following is the declaration of getDisplayName(Locale locale) method:

Parameter

DataTypeParameterDescription
NAlocalelocale is the display name for which a given currency is needed.

Returns

The getDisplayName(Locale locale) method returns the name of invoking currency for the specified locale.

Exceptions

NullPointerException - If the locale is Null.

Compatibility Version

Java 1.7 and above.

Example 1

Output:

US Dollar

Example 2

Output:

Currency: CNY
French display name: yuan renminbi chinois
Korean display name: 중국 위안 인민폐

Example 3

Output:

Indian Rupee
rupia india 
Indian Rupee

Example 4

Output:

Enter the Locale: IT
Enter the Currency: INR
Default locale is: Indian Rupee
Specified locale is: Rupia Indiana

Enter the locale: EN
Enter the Currency: USD
Default locale is: US Dollar
Specified locale is: US Dollar