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

The following examples show how to use java.util.Currency#getCurrencyCode() . 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: Bug4512215.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void testCountryCurrency(String country, String currencyCode,
        int digits) {
    testCurrencyDefined(currencyCode, digits);
    Currency currency = Currency.getInstance(new Locale("", country));
    if (!currency.getCurrencyCode().equals(currencyCode)) {
        throw new RuntimeException("[" + country
                + "] expected: " + currencyCode
                + "; got: " + currency.getCurrencyCode());
    }
}
 
Example 2
Source File: UtilHttp.java    From scipio-erp with Apache License 2.0 5 votes vote down vote up
/**
 * Get the currency string from the session.
 * @param session HttpSession object to use for lookup
 * @return String The ISO currency code
 */
public static String getCurrencyUom(HttpSession session, String appDefaultCurrencyUom) {
    // session, should override all if set there
    String iso = (String) session.getAttribute("currencyUom");

    // check userLogin next, ie if nothing to override in the session
    if (iso == null) {
        Map<String, ?> userLogin = UtilGenerics.cast(session.getAttribute("userLogin"));
        if (userLogin == null) {
            userLogin = UtilGenerics.cast(session.getAttribute("autoUserLogin"));
        }

        if (userLogin != null) {
            iso = (String) userLogin.get("lastCurrencyUom");
        }
    }

    // no user currency? before global default try appDefaultCurrencyUom if specified
    if (iso == null && UtilValidate.isNotEmpty(appDefaultCurrencyUom)) {
        iso = appDefaultCurrencyUom;
    }

    // if none is set we will use the configured default
    if (iso == null) {
        try {
            iso = UtilProperties.getPropertyValue("general", "currency.uom.id.default", "USD");
        } catch (Exception e) {
            Debug.logWarning("Error getting the general:currency.uom.id.default value: " + e.toString(), module);
        }
    }


    // if still none we will use the default for whatever currency we can get...
    if (iso == null) {
        Currency cur = Currency.getInstance(getLocale(session));
        iso = cur.getCurrencyCode();
    }

    return iso;
}
 
Example 3
Source File: Bug4512215.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void testCountryCurrency(String country, String currencyCode,
        int digits) {
    testCurrencyDefined(currencyCode, digits);
    Currency currency = Currency.getInstance(new Locale("", country));
    if (!currency.getCurrencyCode().equals(currencyCode)) {
        throw new RuntimeException("[" + country
                + "] expected: " + currencyCode
                + "; got: " + currency.getCurrencyCode());
    }
}
 
Example 4
Source File: CurrencyTest.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
static void checkCountryCurrency(String countryCode, String expected) {
    Locale locale = new Locale("", countryCode);
    Currency currency = Currency.getInstance(locale);
    String code = (currency != null) ? currency.getCurrencyCode() : null;
    if (!(expected == null ? code == null : expected.equals(code))) {
        throw new RuntimeException("Wrong currency for " +
                locale.getDisplayCountry() +
                ": expected " + expected + ", got " + code);
    }
}
 
Example 5
Source File: CurrencyTest.java    From native-obfuscator with GNU General Public License v3.0 5 votes vote down vote up
static void checkCountryCurrency(String countryCode, String expected) {
    Locale locale = new Locale("", countryCode);
    Currency currency = Currency.getInstance(locale);
    String code = (currency != null) ? currency.getCurrencyCode() : null;
    if (!(expected == null ? code == null : expected.equals(code))) {
        throw new RuntimeException("Wrong currency for " +
                locale.getDisplayCountry() +
                ": expected " + expected + ", got " + code);
    }
}
 
Example 6
Source File: Bug4512215.java    From native-obfuscator with GNU General Public License v3.0 5 votes vote down vote up
private static void testCountryCurrency(String country, String currencyCode,
        int digits) {
    testCurrencyDefined(currencyCode, digits);
    Currency currency = Currency.getInstance(new Locale("", country));
    if (!currency.getCurrencyCode().equals(currencyCode)) {
        throw new RuntimeException("[" + country
                + "] expected: " + currencyCode
                + "; got: " + currency.getCurrencyCode());
    }
}
 
Example 7
Source File: Bug4512215.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static void testCountryCurrency(String country, String currencyCode,
        int digits) {
    testCurrencyDefined(currencyCode, digits);
    Currency currency = Currency.getInstance(new Locale("", country));
    if (!currency.getCurrencyCode().equals(currencyCode)) {
        throw new RuntimeException("[" + country
                + "] expected: " + currencyCode
                + "; got: " + currency.getCurrencyCode());
    }
}
 
Example 8
Source File: StringColumnCurrencyMapper.java    From jadira with Apache License 2.0 4 votes vote down vote up
@Override
public String toNonNullValue(Currency value) {
    return value.getCurrencyCode();
}
 
Example 9
Source File: CurrencyEditor.java    From blog_demos with Apache License 2.0 4 votes vote down vote up
@Override
public String getAsText() {
	Currency value = (Currency) getValue();
	return (value != null ? value.getCurrencyCode() : "");
}
 
Example 10
Source File: ConverterConfiguration.java    From spring-data-examples with Apache License 2.0 4 votes vote down vote up
@Override
public String convert(Currency source) {
	return source.getCurrencyCode();
}
 
Example 11
Source File: CurrencyEditor.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public String getAsText() {
	Currency value = (Currency) getValue();
	return (value != null ? value.getCurrencyCode() : "");
}
 
Example 12
Source File: CurrencyTypeDescriptor.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public String toString(Currency value) {
	return value.getCurrencyCode();
}
 
Example 13
Source File: DecimalFormatSymbols.java    From j2objc with Apache License 2.0 3 votes vote down vote up
/**
 * Sets the currency of these DecimalFormatSymbols.
 * This also sets the currency symbol attribute to the currency's symbol
 * in the DecimalFormatSymbols' locale, and the international currency
 * symbol attribute to the currency's ISO 4217 currency code.
 *
 * @param currency the new currency to be used
 * @exception NullPointerException if <code>currency</code> is null
 * @since 1.4
 * @see #setCurrencySymbol
 * @see #setInternationalCurrencySymbol
 */
public void setCurrency(Currency currency) {
    if (currency == null) {
        throw new NullPointerException();
    }
    this.currency = currency;
    intlCurrencySymbol = currency.getCurrencyCode();
    currencySymbol = currency.getSymbol(locale);
    //cachedIcuDFS = null;
}
 
Example 14
Source File: DecimalFormatSymbols.java    From JDKSourceCode1.8 with MIT License 3 votes vote down vote up
/**
 * Sets the currency of these DecimalFormatSymbols.
 * This also sets the currency symbol attribute to the currency's symbol
 * in the DecimalFormatSymbols' locale, and the international currency
 * symbol attribute to the currency's ISO 4217 currency code.
 *
 * @param currency the new currency to be used
 * @exception NullPointerException if <code>currency</code> is null
 * @since 1.4
 * @see #setCurrencySymbol
 * @see #setInternationalCurrencySymbol
 */
public void setCurrency(Currency currency) {
    if (currency == null) {
        throw new NullPointerException();
    }
    this.currency = currency;
    intlCurrencySymbol = currency.getCurrencyCode();
    currencySymbol = currency.getSymbol(locale);
}
 
Example 15
Source File: DecimalFormatSymbols.java    From jdk8u-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Sets the currency of these DecimalFormatSymbols.
 * This also sets the currency symbol attribute to the currency's symbol
 * in the DecimalFormatSymbols' locale, and the international currency
 * symbol attribute to the currency's ISO 4217 currency code.
 *
 * @param currency the new currency to be used
 * @exception NullPointerException if <code>currency</code> is null
 * @since 1.4
 * @see #setCurrencySymbol
 * @see #setInternationalCurrencySymbol
 */
public void setCurrency(Currency currency) {
    if (currency == null) {
        throw new NullPointerException();
    }
    this.currency = currency;
    intlCurrencySymbol = currency.getCurrencyCode();
    currencySymbol = currency.getSymbol(locale);
}
 
Example 16
Source File: DecimalFormatSymbols.java    From jdk8u60 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Sets the currency of these DecimalFormatSymbols.
 * This also sets the currency symbol attribute to the currency's symbol
 * in the DecimalFormatSymbols' locale, and the international currency
 * symbol attribute to the currency's ISO 4217 currency code.
 *
 * @param currency the new currency to be used
 * @exception NullPointerException if <code>currency</code> is null
 * @since 1.4
 * @see #setCurrencySymbol
 * @see #setInternationalCurrencySymbol
 */
public void setCurrency(Currency currency) {
    if (currency == null) {
        throw new NullPointerException();
    }
    this.currency = currency;
    intlCurrencySymbol = currency.getCurrencyCode();
    currencySymbol = currency.getSymbol(locale);
}
 
Example 17
Source File: DecimalFormatSymbols.java    From jdk8u_jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Sets the currency of these DecimalFormatSymbols.
 * This also sets the currency symbol attribute to the currency's symbol
 * in the DecimalFormatSymbols' locale, and the international currency
 * symbol attribute to the currency's ISO 4217 currency code.
 *
 * @param currency the new currency to be used
 * @exception NullPointerException if <code>currency</code> is null
 * @since 1.4
 * @see #setCurrencySymbol
 * @see #setInternationalCurrencySymbol
 */
public void setCurrency(Currency currency) {
    if (currency == null) {
        throw new NullPointerException();
    }
    this.currency = currency;
    intlCurrencySymbol = currency.getCurrencyCode();
    currencySymbol = currency.getSymbol(locale);
}
 
Example 18
Source File: DecimalFormatSymbols.java    From TencentKona-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Sets the currency of these DecimalFormatSymbols.
 * This also sets the currency symbol attribute to the currency's symbol
 * in the DecimalFormatSymbols' locale, and the international currency
 * symbol attribute to the currency's ISO 4217 currency code.
 *
 * @param currency the new currency to be used
 * @exception NullPointerException if <code>currency</code> is null
 * @since 1.4
 * @see #setCurrencySymbol
 * @see #setInternationalCurrencySymbol
 */
public void setCurrency(Currency currency) {
    if (currency == null) {
        throw new NullPointerException();
    }
    this.currency = currency;
    intlCurrencySymbol = currency.getCurrencyCode();
    currencySymbol = currency.getSymbol(locale);
}
 
Example 19
Source File: DecimalFormatSymbols.java    From jdk1.8-source-analysis with Apache License 2.0 3 votes vote down vote up
/**
 * Sets the currency of these DecimalFormatSymbols.
 * This also sets the currency symbol attribute to the currency's symbol
 * in the DecimalFormatSymbols' locale, and the international currency
 * symbol attribute to the currency's ISO 4217 currency code.
 *
 * @param currency the new currency to be used
 * @exception NullPointerException if <code>currency</code> is null
 * @since 1.4
 * @see #setCurrencySymbol
 * @see #setInternationalCurrencySymbol
 */
public void setCurrency(Currency currency) {
    if (currency == null) {
        throw new NullPointerException();
    }
    this.currency = currency;
    intlCurrencySymbol = currency.getCurrencyCode();
    currencySymbol = currency.getSymbol(locale);
}
 
Example 20
Source File: DecimalFormatSymbols.java    From jdk-1.7-annotated with Apache License 2.0 3 votes vote down vote up
/**
 * Sets the currency of these DecimalFormatSymbols.
 * This also sets the currency symbol attribute to the currency's symbol
 * in the DecimalFormatSymbols' locale, and the international currency
 * symbol attribute to the currency's ISO 4217 currency code.
 *
 * @param currency the new currency to be used
 * @exception NullPointerException if <code>currency</code> is null
 * @since 1.4
 * @see #setCurrencySymbol
 * @see #setInternationalCurrencySymbol
 */
public void setCurrency(Currency currency) {
    if (currency == null) {
        throw new NullPointerException();
    }
    this.currency = currency;
    intlCurrencySymbol = currency.getCurrencyCode();
    currencySymbol = currency.getSymbol(locale);
}