The getSymbol() method is used to get the symbol of a given currency for the default DISPLAY locale.
For example, for the US Dollar, the symbol is "$" if the default locale is the US, while for other locales it may be "US$". If no symbol can be determined, the ISO 4217 currency code is returned.
This is equivalent to calling getSymbol(Locale.getDefault(Locale.Category.DISPLAY)).
Package: java.util
Java Platform: Java SE 8
Syntax:
getSymbol()
Return Value:
the symbol of this currency for the default DISPLAY locale
Return Value Type: String
Example:Java Currency class: getSymbol() Method
import java.util.*;
public class Main {
public static void main(String args[]) {
// Create a currency for INR
Currency cur1 = Currency.getInstance("INR");
// Get and print the symbol of the currency
String symbol = cur1.getSymbol();
System.out.println("Currency symbol is = " + symbol);
}
}
Output:
Currency symbol is = INRpublic String getSymbol(Locale locale)
Gets the symbol of this currency for the specified locale.
For example, for the US Dollar, the symbol is "$" if the specified locale is the US, while for other locales it may be "US$". If no symbol can be determined, the ISO 4217 currency code is returned.
Package: java.util
Java Platform: Java SE 8
Syntax:
getSymbol(Locale locale)
Parameters:
Name Description locale the locale for which a display name for this currency is neededReturn Value:
the symbol of this currency for the specified locale
Return Value Type: String
Throws:
NullPointerException - if locale is null
Example:Java Currency class: getSymbol() 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.getSymbol(locale);
System.out.println("Currency symbol is = " + symbol);
}
}
Output:
Currency symbol is = €
Java Code Editor:
Previous:getNumericcode Method
Next:toString 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