List of usage examples for java.text NumberFormat getNumberInstance
public static final NumberFormat getNumberInstance()
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 ww. ja v 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:NumberFormatRounding.java
public static void main(String[] args) { NumberFormat nf = NumberFormat.getNumberInstance(); nf.setMaximumFractionDigits(2);//from w ww . j av a2s. c o m nf.setRoundingMode(RoundingMode.HALF_DOWN); System.out.println("Default rounding mode: " + nf.getRoundingMode()); System.out.println("123.454 rounds to " + nf.format(123.454)); System.out.println("123.455 rounds to " + nf.format(123.455)); System.out.println("123.456 rounds to " + nf.format(123.456)); System.out.println(); nf.setRoundingMode(RoundingMode.FLOOR); System.out.println("Default rounding mode: " + nf.getRoundingMode()); System.out.println("123.454 rounds to " + nf.format(123.454)); System.out.println("123.455 rounds to " + nf.format(123.455)); System.out.println("123.456 rounds to " + nf.format(123.456)); System.out.println(); nf.setMaximumFractionDigits(2); nf.setRoundingMode(RoundingMode.CEILING); System.out.println("Default rounding mode: " + nf.getRoundingMode()); System.out.println("123.454 rounds to " + nf.format(123.454)); System.out.println("123.455 rounds to " + nf.format(123.455)); System.out.println("123.456 rounds to " + nf.format(123.456)); System.out.println(); }
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:Main.java
public static void main(String[] args) { double value = 9.01236789E9; String text = String.format("%.0f", value); System.out.println(text); // 9012367890 NumberFormat format = NumberFormat.getNumberInstance(); format.setMaximumFractionDigits(0);//from w ww. j a va 2s . c o m format.setGroupingUsed(false); System.out.println(format.format(value)); // 9012367890 }