Java Currency - getDisplayName() Method
The java.util.Currency.getDisplayName() method returns 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.
Syntax
public String getDisplayName()
Parameters
No parameter is required.
Return Value
Returns the display name of this currency for the default DISPLAY locale.
Exception
NA.
Example:
In the example below, the java.util.Currency.getDisplayName() method is used to get the name of the currency using the default locale.
import java.util.*; public class MyClass { public static void main(String[] args) { //creating a currency for UK locale Locale locale = Locale.UK; Currency Curr = Currency.getInstance(locale); //getting and printing the name of the //currency using the default locale String CurrName = Curr.getDisplayName(); System.out.println("Currency Name: " + CurrName); } }
The output of the above code will be:
Currency Name: British Pound
❮ Java.util - Currency