Java.util.Currency.getSymbol( Locale locale ) Method
Description
The java.util.Currency.getSymbol() method Gets the symbol of this currency for the specified locale.
Declaration
Following is the declaration for java.util.Currency.getSymbol() method
public String getSymbol(Locale locale)
Parameters
locale − the locale for which a display name for this currency is needed
Return Value
This method returns currency's symbol for the specified locale.
Exception
NullPointerException − if specified locale is null
Example
The following example shows the usage of java.util.Currency.getSymbol() method.
package com.tutorialspoint;
import java.util.*;
public class CurrencyDemo {
public static void main(String args[]) {
// create a currency for uk locale
Locale locale = Locale.UK;
Currency curr = Currency.getInstance(locale);
// get and print the symbol of the currency
String symbol = curr.getSymbol(locale);
System.out.println("Currency symbol is = " + symbol);
}
}
Let us compile and run the above program, this will produce the following result −
Currency symbol is = £
java_util_currency.htm
Advertisements