Search in sources :

Example 31 with Currency

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

the class TypeTest method testCurrencyType.

@Test
public void testCurrencyType() {
    final Currency original = Currency.getInstance(Locale.US);
    final Currency copy = Currency.getInstance(Locale.US);
    final Currency different = Currency.getInstance(Locale.UK);
    runBasicTests(CurrencyType.INSTANCE, original, copy, different);
}
Also used : Currency(java.util.Currency) Test(org.junit.Test)

Example 32 with Currency

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

the class MonetaryAmountUserType method nullSafeSet.

public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException {
    MonetaryAmount ma = (MonetaryAmount) value;
    BigDecimal amt = ma == null ? null : ma.getAmount();
    Currency cur = ma == null ? null : ma.getCurrency();
    StandardBasicTypes.BIG_DECIMAL.nullSafeSet(st, amt, index, session);
    StandardBasicTypes.CURRENCY.nullSafeSet(st, cur, index + 1, session);
}
Also used : Currency(java.util.Currency) BigDecimal(java.math.BigDecimal)

Example 33 with Currency

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

the class MonetoryAmountUserType method nullSafeSet.

@Override
public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException {
    MonetoryAmount ma = (MonetoryAmount) value;
    BigDecimal amt = ma == null ? null : ma.getAmount();
    Currency cur = ma == null ? null : ma.getCurrency();
    StandardBasicTypes.BIG_DECIMAL.nullSafeSet(st, amt, index, session);
    StandardBasicTypes.CURRENCY.nullSafeSet(st, cur, index + 1, session);
}
Also used : Currency(java.util.Currency) BigDecimal(java.math.BigDecimal)

Example 34 with Currency

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

the class MonetoryAmountUserType method nullSafeGet.

@Override
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 MonetoryAmount(amt, cur);
}
Also used : Currency(java.util.Currency) BigDecimal(java.math.BigDecimal)

Example 35 with Currency

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

the class MonetaryAmountUserType method nullSafeSet.

public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException {
    MonetaryAmount ma = (MonetaryAmount) value;
    BigDecimal amt = ma == null ? null : ma.getAmount();
    Currency cur = ma == null ? null : ma.getCurrency();
    StandardBasicTypes.BIG_DECIMAL.nullSafeSet(st, amt, index, session);
    StandardBasicTypes.CURRENCY.nullSafeSet(st, cur, index + 1, session);
}
Also used : Currency(java.util.Currency) BigDecimal(java.math.BigDecimal)

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