Java Utililty Methods Currency Code Get

List of utility methods to do Currency Code Get

Description

The list of methods to do Currency Code Get are organized into topic(s).

Method

ListcountryCodesForCurrency(String c)
country Codes For Currency
Set<String> codes = new HashSet<>();
if (isValidCode(c)) {
    for (Locale l : Locale.getAvailableLocales()) {
        try {
            Currency currentCurrency = Currency.getInstance(l);
            if (currentCurrency.getCurrencyCode().equals(c)) {
                codes.add(l.getCountry());
        } catch (IllegalArgumentException e) {
return new ArrayList<>(codes);
CurrencycurrencyFromCode(String currency)
currency From Code
try {
    return Currency.getInstance(currency);
} catch (IllegalArgumentException e) {
    return null;
String[]getAvaiableCurrencySymbols()
Returns all the currency symbols
if (_allCurrencySymbols == null) {
    Locale[] locals = Locale.getAvailableLocales();
    ArrayList list = new ArrayList();
    for (int i = 0; i < locals.length; i++) {
        list.add(NumberFormat.getInstance(locals[i]).getCurrency().getSymbol(locals[i]));
    _allCurrencySymbols = (String[]) list.toArray(new String[list.size()]);
    return _allCurrencySymbols;
...
CurrencygetCurrency(final String code)
get Currency
return Currency.getInstance(code);
StringgetCurrencyDisplay(Object amount)
get Currency Display
String display = "";
try {
    if (amount != null && !isEmpty(amount))
        display = NumberFormat.getCurrencyInstance().format(amount);
} catch (IllegalArgumentException ie) {
return display;
StringgetCurrencyNationNumber(double num, int dec)
get Currency Nation Number
NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.CHINA);
nf.setMaximumFractionDigits(dec);
return nf.format(num);
StringgetCurrencyString(long value)
get Currency String
NumberFormat numberFormat = DecimalFormat.getIntegerInstance();
String text = numberFormat.format(value) + " C-Bills";
return text;
CurrencygetDefaultCurrency()
get Default Currency
return NumberFormat.getNumberInstance(Locale.getDefault()).getCurrency();
CurrencygetInstance(String currencyCode)
get Instance
try {
    return Currency.getInstance(currencyCode);
} catch (Exception e) {
    return Currency.getInstance(Locale.US);