Example usage for java.util Currency getCurrencyCode

List of usage examples for java.util Currency getCurrencyCode

Introduction

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

Prototype

public String getCurrencyCode() 

Source Link

Document

Gets the ISO 4217 currency code of this currency.

Usage

From source file:com.trenako.entities.Money.java

/**
 * Creates a new {@code Money}./*  w w  w.ja  va 2s .  co  m*/
 *
 * @param value    the {@code Money} value
 * @param currency the {@code Money} currency
 */
public Money(BigDecimal value, Currency currency) {
    this(intValue(value), currency.getCurrencyCode());
}

From source file:com.prowidesoftware.swift.model.CurrencyAmount.java

/**
 * @param currency a not null currency//from  w  w  w  . j  av a 2s  . co  m
 * @param value the value for the amount, may be <code>null</code>
 */
CurrencyAmount(final Currency currency, Number amount) {
    this(currency.getCurrencyCode(), amount);
}

From source file:com.prowidesoftware.swift.model.CurrencyAmount.java

/**
 * @param currency a not null currency//w  w w.  jav  a 2  s  .  co m
 * @param amount the value for the amount, may be <code>null</code>
 */
CurrencyAmount(final Currency currency, final BigDecimal amount) {
    this(currency.getCurrencyCode(), amount);
}

From source file:com.erudika.para.i18n.CurrencyUtils.java

private CurrencyUtils() {
    Locale[] locales = Locale.getAvailableLocales();
    try {//from  ww  w.  j a  va 2 s  . c om
        for (Locale l : locales) {
            if (!StringUtils.isBlank(l.getCountry())) {
                COUNTRY_TO_LOCALE_MAP.put(l.getCountry(), l);
                Currency c = Currency.getInstance(l);
                if (c != null) {
                    CURRENCY_TO_LOCALE_MAP.put(c.getCurrencyCode(), l);
                    CURRENCIES_MAP.put(c.getCurrencyCode(),
                            getCurrencyName(c.getCurrencyCode(), Locale.US).concat(" ").concat(c.getSymbol(l)));
                }
            }
        }
        // overwrite main locales
        CURRENCY_TO_LOCALE_MAP.put("USD", Locale.US);
        CURRENCY_TO_LOCALE_MAP.put("EUR", Locale.FRANCE);
    } catch (Exception e) {
        logger.error(null, e);
    }
}

From source file:ch.aonyx.broker.ib.api.contract.Contract.java

public void setCurrency(final Currency currency) {
    currencyCode = currency.getCurrencyCode();
}

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

private void sortByCurrencyCode(List<Currency> currencies) {
    //sort by code
    Collections.sort(currencies, new Comparator<Currency>() {
        @Override/*from   w w w.  j ava 2 s . co m*/
        public int compare(Currency o1, Currency o2) {
            return o1.getCurrencyCode().compareTo(o2.getCurrencyCode());
        }
    });
}

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

private Currency findDefaultCurrency(List<Currency> currencies) {
    String username = securityService.getLoggedInUser().getUsername();
    String defaultCurrency = settingsService.getApplicationSettingValue(
            ApplicationSetting.Group.USER_PREFERENCS, ApplicationSettingsService.INVOICES_CURRENCY, username);

    if (!StringUtils.isEmpty(defaultCurrency)) {
        for (Currency currency : currencies) {
            if (defaultCurrency.equals(currency.getCurrencyCode())) {
                return currency;
            }//w ww .ja  v a  2  s  . co  m
        }
    }
    return null;
}

From source file:org.broadleafcommerce.pricing.service.module.CyberSourceTaxModule.java

private void setCurrency(Order order, CyberSourceTaxRequest taxRequest) {
    Currency currency = order.getTotal().getCurrency();
    if (currency == null) {
        currency = Money.defaultCurrency();
    }//from w  ww  .j  av a2 s .  co m
    taxRequest.setCurrency(currency.getCurrencyCode());
}

From source file:org.gnucash.android.ui.chart.PieChartActivity.java

/**
 * Returns a map with a currency code as key and corresponding accounts list
 * as value from a specified list of accounts
 * @param accountList a list of accounts
 * @return a map with a currency code as key and corresponding accounts list as value
 *//*from w ww .  j  a  v  a2s  .  co  m*/
private Map<String, List<Account>> getCurrencyCodeToAccountMap(List<Account> accountList) {
    Map<String, List<Account>> currencyAccountMap = new HashMap<>();
    for (Currency currency : mAccountsDbAdapter.getCurrencies()) {
        currencyAccountMap.put(currency.getCurrencyCode(), new ArrayList<Account>());
    }

    for (Account account : accountList) {
        currencyAccountMap.get(account.getCurrency().getCurrencyCode()).add(account);
    }
    return currencyAccountMap;
}

From source file:org.totschnig.myexpenses.util.Utils.java

public static Currency getSaveInstance(Currency currency) {
    try {//from w w  w .  jav a 2  s  .c  om
        CurrencyEnum.valueOf(currency.getCurrencyCode());
        return currency;
    } catch (IllegalArgumentException e) {
        return Currency.getInstance("EUR");
    }
}