Example usage for java.util Currency getAvailableCurrencies

List of usage examples for java.util Currency getAvailableCurrencies

Introduction

In this page you can find the example usage for java.util Currency getAvailableCurrencies.

Prototype

public static Set<Currency> getAvailableCurrencies() 

Source Link

Document

Gets the set of available currencies.

Usage

From source file:Main.java

public static void main(String args[]) {
    Set<Currency> cSet = Currency.getAvailableCurrencies();
    for (Currency c : cSet) {
        System.out.println(c);//from w w w. j  a v  a 2 s .  c  o  m
    }
}

From source file:Test.java

public static void main(String[] args) {
    Set<Currency> currencies = Currency.getAvailableCurrencies();
    for (Currency currency : currencies) {
        System.out.println("" + currency.getDisplayName() + " - " + currency.getDisplayName(Locale.GERMAN)
                + " - " + currency.getNumericCode());
    }//from  w w w . j av a  2  s . c om

}

From source file:org.zlogic.vogon.web.controller.CurrenciesController.java

/**
 * Creates the wrapped currency list//from   w w w.j a va  2 s.c  o m
 *
 * @return the wrapped currency list
 */
@Bean
public Collection<CurrencyDetails> currencies() {
    List<CurrencyDetails> currencies = new ArrayList<>();
    for (Currency currency : Currency.getAvailableCurrencies())
        currencies.add(new CurrencyDetails(currency));
    Collections.sort(currencies);
    return currencies;
}

From source file:com.pamarin.income.controller.NormalSettingsCtrl.java

public List<Currency> getCurrencys() {
    if (currencys == null) {
        currencys = new ArrayList<>(Currency.getAvailableCurrencies());
        sortBySymbolAscending();//from w  w  w  . j  a va 2s. c  o  m
    }

    return currencys;
}

From source file:de.jfachwert.bank.Waehrung.java

/**
 * Ermittelt aus dem uebergebenen String die entsprechende
 * {@link Currency}.//from w ww .  jav  a 2s. c o  m
 *
 * @param name z.B. "EUR" oder auch ein einzelnes Symbol
 * @return die entsprechende Waehrung
 */
public static Currency toCurrency(String name) {
    try {
        return Currency.getInstance(name);
    } catch (IllegalArgumentException iae) {
        if (name.length() <= 3) {
            for (Currency c : Currency.getAvailableCurrencies()) {
                if (matchesCurrency(name, c)) {
                    return c;
                }
            }
        }
        throw new IllegalArgumentException("cannot get currency for '" + name + "'", iae);
    }
}

From source file:alfio.controller.api.admin.UtilsApiController.java

@RequestMapping(value = "/currencies", method = GET)
public List<CurrencyDescriptor> getCurrencies() {
    return Currency.getAvailableCurrencies().stream().filter(
            c -> c.getDefaultFractionDigits() == 2 && !CURRENCIES_BLACKLIST.contains(c.getCurrencyCode())) //currencies which don't support cents are filtered out. Support will be implemented in the next version
            .map(c -> new CurrencyDescriptor(c.getCurrencyCode(), c.getDisplayName(), c.getSymbol(),
                    c.getDefaultFractionDigits()))
            .collect(Collectors.toList());
}

From source file:de.jfachwert.bank.Waehrung.java

/**
 * Ermittelt die Waehrung. Urspruenglich wurde die Default-Currency ueber
 * <pre>//from w w w.j  a va  2 s .  c o m
 *     Currency.getInstance(Locale.getDefault())
 * </pre>
 * ermittelt. Dies fuehrte aber auf der Sun zu Problemen, da dort
 * die Currency fuer die Default-Locale folgende Exception hervorrief:
 * <pre>
 * java.lang.IllegalArgumentException
 *     at java.util.Currency.getInstance(Currency.java:384)
 *     at de.jfachwert.bank.Geldbetrag.&lt;clinit&gt;
 *     ...
 * </pre>
 *
 * @return normalerweise die deutsche Currency
 */
private static Currency getDefaultCurrency() {
    Locale[] locales = { Locale.getDefault(), Locale.GERMANY, Locale.GERMAN };
    for (Locale loc : locales) {
        try {
            return Currency.getInstance(loc);
        } catch (IllegalArgumentException iae) {
            LOG.log(Level.INFO,
                    "No currency for locale '" + loc + "' available on this machine - will try next one.", iae);
        }
    }
    return Currency.getAvailableCurrencies().iterator().next();
}

From source file:org.businessmanager.geodb.OpenGeoDBImpl.java

@Override
public List<Currency> getListOfCurrencies(String language) {
    List<Currency> currencies = null;
    //return cached list if possible
    if (language == null) {
        currencies = currencyMap.get(Locale.getDefault().getLanguage());
    } else {//from w w  w .j  a v  a 2s  .c  o m
        currencies = currencyMap.get(language);
    }

    if (currencies != null) {
        return currencies;
    }

    Set<Currency> availableCurrencies = Currency.getAvailableCurrencies();
    currencies = new ArrayList<Currency>();
    currencies.addAll(availableCurrencies);

    sortByCurrencyCode(currencies);

    Currency defaultCurrency = findDefaultCurrency(currencies);
    if (defaultCurrency != null) {
        currencies.add(0, defaultCurrency);
    }

    if (language == null) {
        currencyMap.put(Locale.getDefault().getLanguage(), currencies);
    } else {
        currencyMap.put(language, currencies);
    }

    return currencies;
}

From source file:org.orcid.frontend.web.controllers.WorkspaceController.java

@ModelAttribute("currencyCodeTypes")
public Map<String, String> retrieveCurrencyCodesTypesAsMap() {
    Map<String, String> currencyCodeTypes = new LinkedHashMap<String, String>();
    //Add an empty one
    currencyCodeTypes.put("", "");
    for (Currency currency : Currency.getAvailableCurrencies()) {
        currencyCodeTypes.put(currency.getCurrencyCode(), currency.getCurrencyCode());
    }//w ww .j av a2s.  c o m
    return FunctionsOverCollections.sortMapsByValues(currencyCodeTypes);
}