Search in sources :

Example 1 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 2 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 3 with Currency

use of java.util.Currency in project fastjson by alibaba.

the class CurrencyTest4 method test_0.

public void test_0() throws Exception {
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("currency", "CNY");
    String text = JSON.toJSONString(jsonObject);
    Currency currency = JSON.parseObject(text, Currency.class);
    assertSame(Currency.getInstance("CNY"), currency);
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) Currency(java.util.Currency)

Example 4 with Currency

use of java.util.Currency in project fastjson by alibaba.

the class CurrencyTest4 method test_1.

public void test_1() throws Exception {
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("symbol", "CNY");
    String text = JSON.toJSONString(jsonObject);
    Currency currency = JSON.parseObject(text, Currency.class);
    assertSame(Currency.getInstance("CNY"), currency);
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) Currency(java.util.Currency)

Example 5 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)

Aggregations

Currency (java.util.Currency)58 Locale (java.util.Locale)21 BigDecimal (java.math.BigDecimal)8 DecimalFormat (java.text.DecimalFormat)7 DecimalFormatSymbols (java.text.DecimalFormatSymbols)7 NumberFormat (java.text.NumberFormat)6 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 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 ImmutableSortedSet (com.google.common.collect.ImmutableSortedSet)1