Example usage for java.text DecimalFormat format

List of usage examples for java.text DecimalFormat format

Introduction

In this page you can find the example usage for java.text DecimalFormat format.

Prototype

public final String format(double number) 

Source Link

Document

Specialization of format.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    DecimalFormat format = new DecimalFormat();
    format.setNegativeSuffix("minus");
    System.out.println(format.format(-123456789.12345678));

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    DecimalFormat format = new DecimalFormat();
    format.setNegativePrefix("minus");
    System.out.println(format.format(-123456789.12345678));

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    DecimalFormat format = new DecimalFormat("##.##", DecimalFormatSymbols.getInstance());

    System.out.println(format.format(-123456789.12345678));

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    DecimalFormat format = new DecimalFormat();
    format.setPositivePrefix("Positive");
    System.out.println(format.format(123456789.12345678));

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    DecimalFormat format = new DecimalFormat();
    format.setPositiveSuffix("Positive");
    System.out.println(format.format(123456789.12345678));

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    DecimalFormat format = new DecimalFormat();
    format.applyLocalizedPattern("##,##");
    System.out.println(format.format(-123456789.12345678));

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    DecimalFormat format = new DecimalFormat();

    format.setMinimumIntegerDigits(4);/*  ww  w .j av  a 2  s . co m*/

    System.out.println(format.format(123456789.12345678));

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    DecimalFormat format = new DecimalFormat();

    format.setMaximumFractionDigits(4);/*from  ww w .j  av  a2  s.  c  om*/

    System.out.println(format.format(123456789.12345678));

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    DecimalFormat format = new DecimalFormat();

    format.setMinimumFractionDigits(4);/* ww w .j  av a 2 s .com*/

    System.out.println(format.format(123456789.12345678));

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    DecimalFormat format = new DecimalFormat();
    format.setDecimalSeparatorAlwaysShown(false);
    System.out.println(format.format(123456789.12345678));

}