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
public static void main(String[] args) throws Exception { NumberFormat numberFormat = NumberFormat.getNumberInstance(); numberFormat.setCurrency(Currency.getInstance(Locale.CANADA)); numberFormat.setMaximumFractionDigits(2); }
From source file:Main.java
public static void main(String[] args) throws Exception { NumberFormat numberFormat = NumberFormat.getNumberInstance(); numberFormat.setCurrency(Currency.getInstance(Locale.CANADA)); numberFormat.setMaximumIntegerDigits(2); }
From source file:Main.java
public static void main(String[] args) throws Exception { NumberFormat numberFormat = NumberFormat.getNumberInstance(); numberFormat.setCurrency(Currency.getInstance(Locale.CANADA)); numberFormat.setGroupingUsed(true);//from w w w.j av a 2s. c o m }
From source file:Main.java
public static void main(String[] args) throws Exception { NumberFormat numberFormat = NumberFormat.getNumberInstance(); numberFormat.setCurrency(Currency.getInstance(Locale.CANADA)); numberFormat.setParseIntegerOnly(true); }
From source file:Main.java
public static void main(String[] args) throws Exception { NumberFormat numberFormat = NumberFormat.getNumberInstance(); numberFormat.setCurrency(Currency.getInstance(Locale.CANADA)); numberFormat.setMinimumIntegerDigits(2); }
From source file:Main.java
public static void main(String[] args) throws Exception { NumberFormat numberFormat = NumberFormat.getNumberInstance(); numberFormat.setCurrency(Currency.getInstance(Locale.CANADA)); numberFormat.setMinimumFractionDigits(2); }
From source file:Main.java
public static void main(String[] args) throws Exception { NumberFormat numberFormat = NumberFormat.getNumberInstance(); numberFormat.setCurrency(Currency.getInstance(Locale.CANADA)); numberFormat.setRoundingMode(RoundingMode.CEILING); }
From source file:Test.java
public static void main(String[] args) { BigDecimal value = new BigDecimal(12345); Locale.setDefault(Locale.JAPAN); System.out.printf("Default locale: %s\n", Locale.getDefault().getDisplayName()); NumberFormat nf = NumberFormat.getCurrencyInstance(); String formattedCurrency = nf.format(value); System.out.printf("%s\n", formattedCurrency); nf.setCurrency(Currency.getInstance(Locale.US)); formattedCurrency = nf.format(value); System.out.printf("%s\n\n", formattedCurrency); Locale.setDefault(Locale.US); System.out.printf("Default locale: %s\n", Locale.getDefault().getDisplayName()); nf = NumberFormat.getCurrencyInstance(); formattedCurrency = nf.format(value); System.out.printf("%s\n", formattedCurrency); nf.setCurrency(Currency.getInstance("JPY")); formattedCurrency = nf.format(value); System.out.printf("%s\n\n", formattedCurrency); Locale.setDefault(Locale.FRANCE); System.out.printf("Default locale: %s\n", Locale.getDefault().getDisplayName()); nf = NumberFormat.getCurrencyInstance(); formattedCurrency = nf.format(value); System.out.printf("%s\n", formattedCurrency); nf.setCurrency(Currency.getInstance("USD")); formattedCurrency = nf.format(value); System.out.printf("%s\n\n", formattedCurrency); }
From source file:Main.java
public static String getCurrencySymbol() { return Currency.getInstance(Locale.getDefault()).getSymbol(); }
From source file:Main.java
public static String getSpinnertextCountry(String countryCode) { Locale locale = new Locale("", countryCode); try {//from ww w .j ava2 s . c o m Currency currency = Currency.getInstance(locale); return locale.getDisplayCountry() + " (" + currency.getCurrencyCode() + ")"; } catch (Exception e) { } return ""; }