A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.w3resource.com/java-tutorial/util/currency/java_currency_getdisplayname.php below:

Website Navigation


Java Currency Class: getDisplayName() Method

Java Currency Class: getDisplayName() MethodLast update on August 19 2022 21:50:42 (UTC/GMT +8 hours) public String getDisplayName()

The getDisplayName() method is used to get the name that is suitable for display a given 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.

Note: The method is equivalent to calling getDisplayName(Locale.getDefault(Locale.Category.DISPLAY)).

Package: java.util

Java Platform: Java SE 8

Syntax:

getDisplayName()

Return Value:

The display name of this currency for the default DISPLAY locale

Return Value Type: String

Example: Java Currency class: getDisplayName() Method

The following example fills a Java Currency class: getDisplayName() Method.

import java.util.*;

public class Main {
   public static void main(String args[]) {

      // Create 2  currencies
      Currency cr1 = Currency.getInstance("AUD"); //Australian Dollar
      Currency cr2 = Currency.getInstance("USD");  //Japan Yen

      //Display currencY using getDisplayName() method
      System.out.println("AUD Display : "+cr1.getDisplayName());
      System.out.println("USD Display : "+cr2.getSymbol());
     }
}

Output:

AUD Display : Australian Dollar
USD Display : $
public String getDisplayName(Locale locale)

Gets the name that is suitable for displaying this currency for the specified locale.

If there is no suitable display name found for the specified locale, the ISO 4217 currency code is returned.

Package: java.util

Java Platform: Java SE 8

Syntax:

getDisplayName(Locale locale)

Parameters:

Name Description locale   the locale for which a display name for this currency is needed

Return Value:

The display name of this currency for the specified locale.

Return Value Type: String

Example: Java Currency class: getDisplayName() Method

The following example fills a Java Currency class: getDisplayName() Method.

import java.util.*;

public class Main {
   public static void main(String args[]) {

      // Create a currency for GERMANY locale
      Locale locale = Locale.GERMANY;
      Currency cur1 = Currency.getInstance(locale);

      // Get and print the symbol of the currency
      String symbol = cur1.getDisplayName(locale);
      System.out.println("Display name: " + symbol);
   }
}

Output:

Display name: Euro

Java Code Editor:

Previous:getDefaultfractiondigits Method
Next:getInstance Method


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4