java.util.Currency.getSymbol(Locale)
The method java.util.Currency.getSymbol(Locale) gets the symbol of this currency for the specified locale or ISO 4217 currency code.
Method signature
The signature of the java.util.Currency.getSymbol(Locale) method is as follows:
public String getSymbol(Locale locale)
Parameters
- Locale: the locale for which symbol for this currency is needed
Return value
Returns the symbol of this currency for the specified locale or ISO 4217 currency code when the symbol cannot be determined.
Exceptions
- NullPointerException: if locale is null
Example usage
In the following code we use java.util.Currency.getSymbol(Locale):
package com.farenda.java.util; import java.util.Currency; import java.util.Locale; public class CurrencyGetSymbolLocale { public static void main(String[] args) { Locale locale = new Locale("pl", "PL"); Currency currency = Currency.getInstance(locale); // Symbol of Polish PLN in PL locale: System.out.printf("Symbol of %s: %s%n", currency, currency.getSymbol(locale)); // Symbol of Polish PLN in US locale: System.out.printf("Symbol of %s: %s%n", currency, currency.getSymbol(Locale.US)); currency = Currency.getInstance(Locale.US); // Symbol of US Dollar in US locale: System.out.printf("Symbol of %s: %s%n", currency, currency.getSymbol(Locale.US)); } }
The above code produces the following output:
Symbol of PLN: zł Symbol of PLN: PLN Symbol of USD: $