Package java.util

Examples of java.util.Currency$CurrencyNameGetter


     */
    public void test_setInternationalCurrencySymbolLjava_lang_String() {
        Locale locale = Locale.CANADA;
        DecimalFormatSymbols dfs = ((DecimalFormat) NumberFormat
                .getCurrencyInstance(locale)).getDecimalFormatSymbols();
        Currency currency = Currency.getInstance("JPY");
        dfs.setInternationalCurrencySymbol(currency.getCurrencyCode());

        assertTrue("Test1: Returned incorrect currency", currency == dfs
                .getCurrency());
        assertEquals("Test1: Returned incorrect currency symbol", currency
                .getSymbol(locale), dfs.getCurrencySymbol());
        assertTrue("Test1: Returned incorrect international currency symbol",
                currency.getCurrencyCode().equals(
                        dfs.getInternationalCurrencySymbol()));

        dfs.setInternationalCurrencySymbol("bogus");
        // RI support this legacy country code
        // assertNotNull("Test2: Returned incorrect currency", dfs.getCurrency());
View Full Code Here


    }

    // Test serialization mechanism of DecimalFormatSymbols
    public void test_serialization() throws Exception {
        DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.FRANCE);
        Currency currency = symbols.getCurrency();
        assertNotNull(currency);

        // serialize
        ByteArrayOutputStream byteOStream = new ByteArrayOutputStream();
        ObjectOutputStream objectOStream = new ObjectOutputStream(byteOStream);
View Full Code Here

        DecimalFormat format = (DecimalFormat) DecimalFormat.getInstance(Locale.US);
        DecimalFormat cloned = (DecimalFormat) format.clone();
        cloned.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.US));
        assertEquals(format, cloned);

        Currency c = Currency.getInstance(Locale.US);
        cloned.setCurrency(c);

        assertEquals(format, cloned);
    }
View Full Code Here

    /**
     * @tests java.text.DecimalFormat#getCurrency()
     */
    //FIXME This test fails on Harmony ClassLibrary
    public void test_getCurrency() {
        Currency currK = Currency.getInstance("KRW");
        Currency currX = Currency.getInstance("XXX");
        Currency currE = Currency.getInstance("EUR");
        Currency curr01;

        DecimalFormat df = (DecimalFormat) NumberFormat
                .getCurrencyInstance(new Locale("ko", "KR"));
        assertTrue("Test1: Returned incorrect currency",
                df.getCurrency() == currK);
View Full Code Here

            df.setCurrency(null);
            fail("Expected NullPointerException");
        } catch (NullPointerException e) {
        }

        Currency currency = Currency.getInstance("AED");
        df.setCurrency(currency);
        assertTrue("Returned incorrect currency", currency == df.getCurrency());
        assertTrue("Returned incorrect currency symbol", currency.getSymbol(
                locale)
                .equals(df.getDecimalFormatSymbols().getCurrencySymbol()));
        assertTrue("Returned incorrect international currency symbol", currency
                .getCurrencyCode().equals(
                        df.getDecimalFormatSymbols()
                                .getInternationalCurrencySymbol()));
    }
View Full Code Here

     * @param icu the object which receives the new values. @param dfs the
     * object which contains the new values.
     */
    private void copySymbols(final com.ibm.icu.text.DecimalFormatSymbols icu,
            final DecimalFormatSymbols dfs) {
        Currency currency = dfs.getCurrency();
        if (currency == null) {
            icu.setCurrency(com.ibm.icu.util.Currency.getInstance("XXX")); //$NON-NLS-1$
        } else {
            icu.setCurrency(com.ibm.icu.util.Currency.getInstance(dfs
                    .getCurrency().getCurrencyCode()));
View Full Code Here

    private static Map<String, String> getAllCurrencies() {
        Map<String, String> currencies = new TreeMap<String, String>();
        for (Locale locale : Locale.getAvailableLocales()) {
            if (StringUtils.isNotBlank(locale.getCountry())) {
                Currency currency = Currency.getInstance(locale);
                currencies.put(currency.getCurrencyCode(),
                        currency.getSymbol(locale));
            }
        }
        return currencies;
    }
View Full Code Here

        DateTime effective = ISODateTimeFormat.dateTimeParser().parseDateTime(
                properties.getProperty("effective"));
        String symbol = properties.getProperty("symbol");
        BigDecimal price = new BigDecimal(
                properties.getProperty("price"));
        Currency currency = Currency.getInstance(
                properties.getProperty("currency"));

        return new MarketPrice(
                symbol, new Money(price, currency), effective);
    }
View Full Code Here

        testInvalidCurrency("US$");
        testInvalidCurrency("\u20AC");
    }

    static void testValidCurrency(String currencyCode) {
        Currency currency1 = Currency.getInstance(currencyCode);
        Currency currency2 = Currency.getInstance(currencyCode);
        if (currency1 != currency2) {
            throw new RuntimeException("Didn't get same instance for same currency code");
        }
        if (!currency1.getCurrencyCode().equals(currencyCode)) {
            throw new RuntimeException("Currency code changed");
View Full Code Here

    }

    static void testInvalidCurrency(String currencyCode) {
        boolean gotException = false;
        try {
            Currency currency = Currency.getInstance(currencyCode);
        } catch (IllegalArgumentException e) {
            gotException = true;
        }
        if (!gotException) {
            throw new RuntimeException("didn't get specified exception");
View Full Code Here

TOP

Related Classes of java.util.Currency$CurrencyNameGetter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.