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:Main.java
@TargetApi(Build.VERSION_CODES.KITKAT) public static String[] get_Currency_Name_And_Currency_Code(String iso2) { String[] str = new String[2]; Locale locale = new Locale("", iso2); Currency currency = Currency.getInstance(locale); str[0] = currency.getDisplayName(Locale.ENGLISH); str[1] = currency.toString();//from www . j av a 2 s. c o m return str; }
From source file:Main.java
public static String getCountryCode(String spinnerText) { String[] locales = Locale.getISOCountries(); ArrayList<String> countries = new ArrayList<>(); for (String countryCode : locales) { Locale locale = new Locale("", countryCode); try {//w w w. j av a 2s . co m Currency currency = Currency.getInstance(locale); String proposedSpinnerText = locale.getDisplayCountry() + " (" + currency.getCurrencyCode() + ")"; if (proposedSpinnerText.equals(spinnerText)) { return countryCode; } } catch (Exception e) { } } return ""; }
From source file:Main.java
public static ArrayList<String> getCountriesArray() { String[] locales = Locale.getISOCountries(); ArrayList<String> countries = new ArrayList<String>(); for (String countryCode : locales) { Locale locale = new Locale("", countryCode); try {//from ww w .j a v a 2 s. c om Currency currency = Currency.getInstance(locale); countries.add(locale.getDisplayCountry() + " (" + currency.getCurrencyCode() + ")"); } catch (Exception e) { } } Collections.sort(countries); return countries; }
From source file:Main.java
public static ArrayList<String> getCountriesArray1() { Locale[] locales = Locale.getAvailableLocales(); ArrayList<String> countries = new ArrayList<String>(); for (Locale locale : locales) { String country = locale.getDisplayCountry(); Currency currency = Currency.getInstance(locale); if (country.trim().length() > 0 && !countries.contains(country) && !country.trim().equals("World")) { countries.add(country + " (" + currency + ")"); }/* w w w . j a v a 2 s .c om*/ } Collections.sort(countries); setCountriesISOMap(); return countries; }
From source file:Main.java
@NonNull static String convertAmount(int amount) { DecimalFormat formatter = (DecimalFormat) NumberFormat.getCurrencyInstance(); formatter.setCurrency(Currency.getInstance("EUR")); String symbol = formatter.getCurrency().getSymbol(); formatter.setNegativePrefix(symbol + "-"); formatter.setNegativeSuffix(""); return formatter.format((double) amount / 100.0); }
From source file:com.trenako.validation.MoneyValidator.java
private static boolean validCurrency(Money m) { if (StringUtils.isBlank(m.getCurrency())) return false; try {//from www . j a v a 2 s .c o m Currency.getInstance(m.getCurrency()); return true; } catch (IllegalArgumentException ex) { // currencyCode is not a supported ISO 4217 code } return false; }
From source file:com.pamarin.income.controller.LocaleCtrl.java
public void reset() { if (!SecurityUtils.isAnonymous()) { Settings settings = SecurityUtils.getUser().getSettings(); currency = Currency.getInstance(settings.getCurrencyCode()); }//from ww w. j a v a 2s .co m }
From source file:org.mayocat.shop.catalog.configuration.jackson.MoneyTest.java
@Test public void testCurrencyDeserialization() throws Exception { Assert.assertEquals(Currency.getInstance("EUR"), mapper.readValue("\"EUR\"", Currency.class)); }
From source file:com.elasticgrid.model.internal.jibx.Conversion.java
public static Currency deserializeCurrency(String currencyCode) { return Currency.getInstance(currencyCode); }
From source file:com.switchfly.inputvalidation.sanitizer.CurrencyCodeSanitizer.java
@Override public String execute(String content) { if (StringUtils.isBlank(content)) { return content; }// w w w. j a va 2 s.c o m try { return Currency.getInstance(StringUtils.upperCase(content)).toString(); } catch (Exception e) { HtmlSanitizer htmlSanitizer = new HtmlSanitizer(); String sanitized = htmlSanitizer.execute(content); _logger.warn("Invalid currency code (" + sanitized + "). Setting currency code to \"USD\"."); return "USD"; } }