List of usage examples for java.text NumberFormat setCurrency
public void setCurrency(Currency currency)
From source file:Main.java
public static void main(String[] args) throws Exception { NumberFormat numberFormat = NumberFormat.getNumberInstance(); numberFormat.setCurrency(Currency.getInstance(Locale.CANADA)); }
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 a v a2s . 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:org.totschnig.myexpenses.Utils.java
/** * formats an amount with a currency/*from www. j a v a 2 s . c om*/ * @param amount * @param currency * @return formated string */ static String formatCurrency(float amount, Currency currency) { NumberFormat nf = NumberFormat.getCurrencyInstance(); nf.setCurrency(currency); return nf.format(amount); }