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:de.jfachwert.bank.Waehrung.java

private static boolean matchesCurrency(String name, Currency c) {
    return name.equalsIgnoreCase(c.getCurrencyCode()) || name.equalsIgnoreCase(c.getSymbol());
}

From source file:com.prowidesoftware.swift.utils.SwiftFormatUtils.java

/**
 * Gets the currency code from the parameter Currency.
 * @param currency Currency to use/* www  . j a v  a2  s .  c o m*/
 * @return the string with the currency code
 * @since 6.4
 */
public static String getCurrency(final Currency currency) {
    return currency.getCurrencyCode();
}

From source file:org.openestate.io.immobiliare_it.ImmobiliareItUtils.java

public static String printCurrency(Currency value) {
    if (value == null)
        throw new IllegalArgumentException("Can't print currency value!");
    else// w w w  .  jav  a 2  s. c  o m
        return value.getCurrencyCode();
}

From source file:org.libreplan.web.common.ConfigurationModel.java

private static Map<String, String> getAllCurrencies() {
    Map<String, String> currencies = new TreeMap<>();
    for (Locale locale : Locale.getAvailableLocales()) {
        if (StringUtils.isNotBlank(locale.getCountry())) {
            Currency currency = Currency.getInstance(locale);
            currencies.put(currency.getCurrencyCode(), currency.getSymbol(locale));
        }/*  www. ja  va2  s.c o  m*/
    }
    return currencies;
}

From source file:de.javakaffee.web.msm.integration.TestUtils.java

public static void assertDeepEquals(final Object one, final Object another,
        final Map<Object, Object> alreadyChecked) {
    if (one == another) {
        return;/*  ww w .  ja v  a2s. c  o  m*/
    }
    if (one == null && another != null || one != null && another == null) {
        Assert.fail("One of both is null: " + one + ", " + another);
    }
    if (alreadyChecked.containsKey(one)) {
        return;
    }
    alreadyChecked.put(one, another);

    Assert.assertEquals(one.getClass(), another.getClass());
    if (one.getClass().isPrimitive() || one instanceof String || one instanceof Character
            || one instanceof Boolean) {
        Assert.assertEquals(one, another);
        return;
    }

    if (Map.class.isAssignableFrom(one.getClass())) {
        final Map<?, ?> m1 = (Map<?, ?>) one;
        final Map<?, ?> m2 = (Map<?, ?>) another;
        Assert.assertEquals(m1.size(), m2.size());
        for (final Map.Entry<?, ?> entry : m1.entrySet()) {
            assertDeepEquals(entry.getValue(), m2.get(entry.getKey()));
        }
        return;
    }

    if (Set.class.isAssignableFrom(one.getClass())) {
        final Set<?> m1 = (Set<?>) one;
        final Set<?> m2 = (Set<?>) another;
        Assert.assertEquals(m1.size(), m2.size());
        final Iterator<?> iter1 = m1.iterator();
        final Iterator<?> iter2 = m2.iterator();
        while (iter1.hasNext()) {
            assertDeepEquals(iter1.next(), iter2.next());
        }
        return;
    }

    if (Number.class.isAssignableFrom(one.getClass())) {
        Assert.assertEquals(((Number) one).longValue(), ((Number) another).longValue());
        return;
    }

    if (one instanceof Currency) {
        // Check that the transient field defaultFractionDigits is initialized correctly (that was issue #34)
        final Currency currency1 = (Currency) one;
        final Currency currency2 = (Currency) another;
        Assert.assertEquals(currency1.getCurrencyCode(), currency2.getCurrencyCode());
        Assert.assertEquals(currency1.getDefaultFractionDigits(), currency2.getDefaultFractionDigits());
    }

    Class<? extends Object> clazz = one.getClass();
    while (clazz != null) {
        assertEqualDeclaredFields(clazz, one, another, alreadyChecked);
        clazz = clazz.getSuperclass();
    }

}

From source file:de.javakaffee.kryoserializers.KryoTest.java

private static void assertDeepEquals(final Object one, final Object another,
        final Map<Object, Object> alreadyChecked) throws Exception {
    if (one == another) {
        return;/*  w w w  .jav a2s  . co  m*/
    }
    if (one == null && another != null || one != null && another == null) {
        Assert.fail("One of both is null: " + one + ", " + another);
    }
    if (alreadyChecked.containsKey(one)) {
        return;
    }
    alreadyChecked.put(one, another);

    Assert.assertEquals(one.getClass(), another.getClass());
    if (one.getClass().isPrimitive() || one instanceof String || one instanceof Character
            || one instanceof Boolean || one instanceof Class<?>) {
        Assert.assertEquals(one, another);
        return;
    }

    if (Map.class.isAssignableFrom(one.getClass())) {
        final Map<?, ?> m1 = (Map<?, ?>) one;
        final Map<?, ?> m2 = (Map<?, ?>) another;
        Assert.assertEquals(m1.size(), m2.size());
        final Iterator<? extends Map.Entry<?, ?>> iter1 = m1.entrySet().iterator();
        final Iterator<? extends Map.Entry<?, ?>> iter2 = m2.entrySet().iterator();
        while (iter1.hasNext()) {
            Assert.assertTrue(iter2.hasNext());
            assertDeepEquals(iter1.next(), iter2.next(), alreadyChecked);
        }
        return;
    }

    if (Number.class.isAssignableFrom(one.getClass())) {
        Assert.assertEquals(((Number) one).longValue(), ((Number) another).longValue());
        return;
    }

    if (one instanceof Currency) {
        // Check that the transient field defaultFractionDigits is initialized correctly (that was issue #34)
        final Currency currency1 = (Currency) one;
        final Currency currency2 = (Currency) another;
        Assert.assertEquals(currency1.getCurrencyCode(), currency2.getCurrencyCode());
        Assert.assertEquals(currency1.getDefaultFractionDigits(), currency2.getDefaultFractionDigits());
    }

    Class<? extends Object> clazz = one.getClass();
    while (clazz != null) {
        assertEqualDeclaredFields(clazz, one, another, alreadyChecked);
        clazz = clazz.getSuperclass();
    }

}

From source file:org.codehaus.groovy.grails.web.binding.CurrencyEditor.java

@Override
public String getAsText() {
    Currency c = (Currency) getValue();
    if (c == null) {
        return "";
    }/*from w  w w.ja va2 s  . c o  m*/

    return c.getCurrencyCode();
}

From source file:groovyx.gaelyk.graelyk.cast.CurrencyEditor.java

public String getAsText() {
    Currency c = (Currency) getValue();
    if (c == null) {
        return "";
    } else {/*from w w w. j  ava  2 s  .  c om*/
        return c.getCurrencyCode();
    }
}

From source file:org.zalando.jackson.datatype.money.CurrencySerializer.java

@Override
public void serialize(final Currency value, final JsonGenerator generator, final SerializerProvider serializers)
        throws IOException {
    generator.writeString(value.getCurrencyCode());
}

From source file:to.sparks.mtgox.service.HTTPClientV1Service.java

public CurrencyInfo getCurrencyInfo(Currency currency) throws IOException, Exception {
    return getCurrencyInfo(currency.getCurrencyCode());
}