List of usage examples for java.util Currency getInstance
public static Currency getInstance(Locale locale)
Currency
instance for the country of the given locale. From source file:org.yccheok.jstock.gui.OptionsSellAdvisorJPanel.java
private static ComboBoxModel getComboBoxModel() { synchronized (defaultComboBoxModel) { if (defaultComboBoxModel.getSize() > 0) { return defaultComboBoxModel; }// www . jav a 2s . c o m String[] countries = { "AU", // Austrialia "AT", // Austria "BE", // Belgium "BR", // Brazil "CA", // Canada "CN", // China "CZ", // Czech "DK", // Denmark "FR", // France "DE", // Germany "HK", // HongKong "HU", // Hungary "IN", // India "ID", // Indonesia "IT", // Italy "KR", // Korea "MY", // Malaysia "NL", // Netherlands "NZ", // NewZealand "NO", // Norway "PT", // Portugal "SG", // Singapore "ES", // Spain "SE", // Sweden "CH", // Switzerland "TW", // Taiwan "GB", // Unitedkingdom "US", // UnitedState }; final List<String> countryList = Arrays.asList(countries); final Locale[] locales = Locale.getAvailableLocales(); // Order is important. final Set<String> set = new LinkedHashSet<String>(); set.add(Utils.getDefaultCurrencySymbol()); for (Locale locale : locales) { if (countryList.contains(locale.getCountry()) == false) { continue; } set.add(Currency.getInstance(locale).getSymbol(locale)); } for (String s : set) { defaultComboBoxModel.addElement(s); } } return defaultComboBoxModel; }
From source file:de.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderTest.java
@DataProvider(name = "typesAsSessionAttributesProvider") protected Object[][] createTypesAsSessionAttributesData() { return new Object[][] { { int.class, 42 }, { long.class, 42 }, { Boolean.class, Boolean.TRUE }, { String.class, "42" }, { StringBuilder.class, new StringBuilder("42") }, { StringBuffer.class, new StringBuffer("42") }, { Class.class, String.class }, { Long.class, Long.valueOf(42) }, { Integer.class, Integer.valueOf(42) }, { Character.class, Character.valueOf('c') }, { Byte.class, Byte.valueOf("b".getBytes()[0]) }, { Double.class, Double.valueOf(42d) }, { Float.class, Float.valueOf(42f) }, { Short.class, Short.valueOf((short) 42) }, { BigDecimal.class, new BigDecimal(42) }, { AtomicInteger.class, new AtomicInteger(42) }, { AtomicLong.class, new AtomicLong(42) }, { MutableInt.class, new MutableInt(42) }, { Integer[].class, new Integer[] { 42 } }, { Date.class, new Date(System.currentTimeMillis() - 10000) }, { Calendar.class, Calendar.getInstance() }, { Currency.class, Currency.getInstance("EUR") }, { ArrayList.class, new ArrayList<String>(Arrays.asList("foo")) }, { int[].class, new int[] { 1, 2 } }, { long[].class, new long[] { 1, 2 } }, { short[].class, new short[] { 1, 2 } }, { float[].class, new float[] { 1, 2 } }, { double[].class, new double[] { 1, 2 } }, { int[].class, new int[] { 1, 2 } }, { byte[].class, "42".getBytes() }, { char[].class, "42".toCharArray() }, { String[].class, new String[] { "23", "42" } }, { Person[].class, new Person[] { createPerson("foo bar", Gender.MALE, 42) } } }; }
From source file:org.restcomm.connect.http.SmsMessagesEndpoint.java
private SmsMessage sms(final Sid accountSid, final String apiVersion, final String sender, final String recipient, final String body, final SmsMessage.Status status, final SmsMessage.Direction direction) { final SmsMessage.Builder builder = SmsMessage.builder(); final Sid sid = Sid.generate(Sid.Type.SMS_MESSAGE); builder.setSid(sid);// w ww . j av a 2 s . c om builder.setAccountSid(accountSid); builder.setSender(sender); builder.setRecipient(recipient); builder.setBody(body); builder.setStatus(status); builder.setDirection(direction); builder.setPrice(new BigDecimal(0.00)); // TODO - this needs to be added as property to Configuration somehow builder.setPriceUnit(Currency.getInstance("USD")); builder.setApiVersion(apiVersion); final StringBuilder buffer = new StringBuilder(); buffer.append("/").append(apiVersion).append("/Accounts/"); buffer.append(accountSid.toString()).append("/SMS/Messages/"); buffer.append(sid.toString()); final URI uri = URI.create(buffer.toString()); builder.setUri(uri); return builder.build(); }
From source file:org.broadleafcommerce.vendor.paypal.service.payment.PayPalResponseGeneratorImpl.java
protected void addRefundData(String rawResponse, PayPalPaymentResponse response) { PayPalRefundInfo refundInfo = new PayPalRefundInfo(); response.setRefundInfo(refundInfo);/* w w w . j a va 2 s . c o m*/ String currencyCode = getResponseValue(rawResponse, MessageConstants.CURRENCYCODE); refundInfo.setCurrencyCode(currencyCode); refundInfo.setRefundTransactionId(getResponseValue(rawResponse, MessageConstants.REFUNDTRANSACTIONID)); String feeRefundAmount = getResponseValue(rawResponse, MessageConstants.FEEREFUNDAMT); if (!StringUtils.isEmpty(feeRefundAmount)) { refundInfo.setFeeRefundAmount(new Money(feeRefundAmount, Currency.getInstance(currencyCode))); } String grossRefundAmount = getResponseValue(rawResponse, MessageConstants.GROSSREFUNDAMT); if (!StringUtils.isEmpty(grossRefundAmount)) { refundInfo.setGrossRefundAmount(new Money(grossRefundAmount, Currency.getInstance(currencyCode))); } String netRefundAmount = getResponseValue(rawResponse, MessageConstants.NETREFUNDAMT); if (!StringUtils.isEmpty(netRefundAmount)) { refundInfo.setNetRefundAmount(new Money(netRefundAmount, Currency.getInstance(currencyCode))); } String totalRefundAmount = getResponseValue(rawResponse, MessageConstants.TOTALREFUNDEDAMT); if (!StringUtils.isEmpty(totalRefundAmount)) { refundInfo.setTotalRefundAmount(new Money(totalRefundAmount, Currency.getInstance(currencyCode))); } refundInfo.setRefundInfo(getResponseValue(rawResponse, MessageConstants.REFUNDINFO)); String refundStatus = getResponseValue(rawResponse, MessageConstants.REFUNDSTATUS); if (!StringUtils.isEmpty(refundStatus)) { refundInfo.setRefundStatusType(PayPalRefundStatusType.getInstance(refundStatus)); } String pendingReason = getResponseValue(rawResponse, MessageConstants.PENDINGREASON); if (!StringUtils.isEmpty(pendingReason)) { refundInfo.setPendingReasonType(PayPalRefundPendingReasonType.getInstance(pendingReason)); } }
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. j a v a 2s .com*/ } return currencies; }
From source file:de.javakaffee.kryoserializers.KryoTest.java
@Test(enabled = true) public void testCurrency() throws Exception { final Currency currency = Currency.getInstance("EUR"); final Currency deserialized = deserialize(serialize(currency), Currency.class); assertDeepEquals(deserialized, currency); // Check that the transient field defaultFractionDigits is initialized correctly Assert.assertEquals(deserialized.getCurrencyCode(), currency.getCurrencyCode()); Assert.assertEquals(deserialized.getDefaultFractionDigits(), currency.getDefaultFractionDigits()); }
From source file:de.schildbach.pte.NegentweeProvider.java
private Fare fareFromJSONObject(JSONObject fareLeg) throws JSONException { JSONArray fares = fareLeg.getJSONArray("fares"); float farePrice = 0; for (int j = 0; j < fares.length(); j++) { JSONObject fare = fares.getJSONObject(j); // Always get the full non-reduced 2nd class fare price String fareClass = fare.getString("class"); if (!fare.getBoolean("reduced") && (fareClass.equals("none") || fareClass.equals("second"))) { farePrice = (fare.getInt("eurocents") / 100); break; }// w w w . j a v a 2 s.c om } return new Fare(fareLeg.getString("operatorString"), Fare.Type.ADULT, Currency.getInstance("EUR"), farePrice, null, null); }
From source file:com.concursive.connect.web.modules.productcatalog.dao.Product.java
/** * Description of the Method//from ww w . j a v a2s.c om * * @return Description of the Return Value */ public String toString() { NumberFormat formatter = NumberFormat.getCurrencyInstance(); Currency currency = Currency.getInstance("USD"); formatter.setCurrency(currency); StringBuffer out = new StringBuffer(); out.append("Product: " + this.getName() + "\r\n"); out.append("Description: " + this.getPriceDescription() + "\r\n"); if (sku != null) { out.append("Sku: " + this.getSku() + "\r\n"); } out.append("Price: " + formatter.format(this.getTotalPrice()) + "\r\n"); out.append("Configuration: " + this.getConfiguredSummary() + "\r\n"); if (orderDescription != null) { out.append("Additional Information: " + this.getOrderDescription() + "\r\n"); } out.append("\r\n"); return out.toString(); }
From source file:com.prowidesoftware.swift.utils.SwiftFormatUtils.java
/** * Tell if <code>string</code> is a valid currency code using Currency isntances from Java * @param string the string to test for a currency code * @return true if string is a valid currency code and false in other case, including null and empty *///from ww w .j a v a 2 s . co m public static boolean isCurrency(final String string) { if (StringUtils.isNotBlank(string)) { try { return Currency.getInstance(string) != null; } catch (final Exception ignored) { } } return false; }
From source file:org.kuali.kra.proposaldevelopment.printing.xmlstream.ProposalDevelopmentXmlStream.java
private String getCurrencyFormat(BigDecimal amount) { NumberFormat currencyFormater = new DecimalFormat("###,###,##0"); currencyFormater.setCurrency(Currency.getInstance(Locale.US)); return currencyFormater.format(amount.doubleValue()); }