Search in sources :

Example 11 with Currency

use of java.util.Currency in project hibernate-orm by hibernate.

the class MonetaryAmountUserType method nullSafeGet.

public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws HibernateException, SQLException {
    BigDecimal amt = StandardBasicTypes.BIG_DECIMAL.nullSafeGet(rs, names[0], session);
    Currency cur = StandardBasicTypes.CURRENCY.nullSafeGet(rs, names[1], session);
    if (amt == null)
        return null;
    return new MonetaryAmount(amt, cur);
}
Also used : Currency(java.util.Currency) BigDecimal(java.math.BigDecimal)

Example 12 with Currency

use of java.util.Currency in project camel by apache.

the class InstanceFallbackConverterTest method testInstanceFallbackConverter.

public void testInstanceFallbackConverter() throws Exception {
    Exchange exchange = new DefaultExchange(context);
    Currency cur = Currency.getInstance(Locale.US);
    String money = context.getTypeConverter().convertTo(String.class, exchange, cur);
    assertEquals("Money talks says " + context.getName(), money);
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Currency(java.util.Currency)

Example 13 with Currency

use of java.util.Currency in project camel by apache.

the class InstanceFallbackConverterTest method testInstanceFallbackMandatoryConverter.

public void testInstanceFallbackMandatoryConverter() throws Exception {
    Exchange exchange = new DefaultExchange(context);
    Currency cur = Currency.getInstance(Locale.US);
    String money = context.getTypeConverter().mandatoryConvertTo(String.class, exchange, cur);
    assertEquals("Money talks says " + context.getName(), money);
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Currency(java.util.Currency)

Example 14 with Currency

use of java.util.Currency in project hibernate-orm by hibernate.

the class MonetaryAmountUserType method nullSafeGet.

@Override
public Object nullSafeGet(ResultSet resultSet, String[] names, SharedSessionContractImplementor session, Object owner) throws HibernateException, SQLException {
    BigDecimal value = resultSet.getBigDecimal(names[0]);
    if (resultSet.wasNull()) {
        return null;
    }
    String cur = resultSet.getString(names[1]);
    Currency userCurrency = Currency.getInstance(cur);
    return new MonetaryAmount(value, userCurrency);
}
Also used : Currency(java.util.Currency) BigDecimal(java.math.BigDecimal)

Example 15 with Currency

use of java.util.Currency in project jackson-databind by FasterXML.

the class JDKStringLikeTypesTest method testCurrency.

public void testCurrency() throws IOException {
    Currency usd = Currency.getInstance("USD");
    assertEquals(usd, new ObjectMapper().readValue(quote("USD"), Currency.class));
}
Also used : Currency(java.util.Currency)

Aggregations

Currency (java.util.Currency)60 Locale (java.util.Locale)21 BigDecimal (java.math.BigDecimal)8 NumberFormat (java.text.NumberFormat)8 DecimalFormat (java.text.DecimalFormat)7 DecimalFormatSymbols (java.text.DecimalFormatSymbols)7 ChoiceFormat (java.text.ChoiceFormat)3 HashSet (java.util.HashSet)3 JSONObject (com.alibaba.fastjson.JSONObject)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ObjectInputStream (java.io.ObjectInputStream)2 ObjectOutputStream (java.io.ObjectOutputStream)2 ParsePosition (java.text.ParsePosition)2 ArrayList (java.util.ArrayList)2 Exchange (org.apache.camel.Exchange)2 DefaultExchange (org.apache.camel.impl.DefaultExchange)2 JSONException (org.json.JSONException)2 JSONObject (org.json.JSONObject)2 ImmutableSet (com.google.common.collect.ImmutableSet)1