Java Code Examples for java.util.Currency#getDisplayName()

The following examples show how to use java.util.Currency#getDisplayName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CurrencyTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
public void test_getDisplayName_null() {
    Currency currency = Currency.getInstance("CHF");
    try {
        currency.getDisplayName(null);
        fail();
    } catch (NullPointerException expected) {
    }
}
 
Example 2
Source File: FiatCurrency.java    From bisq-core with GNU Affero General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("WeakerAccess")
public FiatCurrency(Currency currency, Locale locale) {
    super(currency.getCurrencyCode(), currency.getDisplayName(locale));
    this.currency = currency;
}
 
Example 3
Source File: FiatCurrency.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("WeakerAccess")
public FiatCurrency(Currency currency, Locale locale) {
    super(currency.getCurrencyCode(), currency.getDisplayName(locale));
    this.currency = currency;
}
 
Example 4
Source File: CurrencyToken.java    From jsr354-ri with Apache License 2.0 3 votes vote down vote up
/**
 * This method tries to evaluate the localized display name for a
 * {@link CurrencyUnit}. It uses {@link Currency#getDisplayName(Locale)} if
 * the given currency code maps to a JDK {@link Currency} instance.
 * <p>
 * If not found {@code currency.getCurrencyCode()} is returned.
 *
 * @param currency The currency, not {@code null}
 * @return the formatted currency name.
 */
private String getCurrencyName(CurrencyUnit currency) {
    Currency jdkCurrency = getCurrency(currency.getCurrencyCode());
    if (Objects.nonNull(jdkCurrency)) {
        return jdkCurrency.getDisplayName(locale);
    }
    return currency.getCurrencyCode();
}