Example usage for java.util Formatter Formatter

List of usage examples for java.util Formatter Formatter

Introduction

In this page you can find the example usage for java.util Formatter Formatter.

Prototype

public Formatter() 

Source Link

Document

Constructs a new formatter.

Usage

From source file:MainClass.java

public static void main(String args[]) {
    Formatter fmt = new Formatter();

    fmt.format("%E", 123.1234);
    System.out.println(fmt);//from  w w w  . ja va2 s  . com

}

From source file:MainClass.java

public static void main(String args[]) {
    Formatter fmt = new Formatter();
    // Format 4 decimal places.
    fmt = new Formatter();
    fmt.format("%16.2e", 123.1234567);
    System.out.println(fmt);//from ww  w . j a  va2s.com
}

From source file:MainClass.java

public static void main(String args[]) {
    Formatter fmt = new Formatter();

    fmt = new Formatter();
    fmt.format("%.15s", "Formatting with Java is now easy.");
    System.out.println(fmt);//from   w ww . ja  v  a2 s.  c o  m
}

From source file:MainClass.java

public static void main(String args[]) {
    Formatter fmt = new Formatter();

    fmt.format("%(d", -100);
    System.out.println(fmt);//from   ww w.  java2 s . co m

}

From source file:MainClass.java

public static void main(String args[]) {
    Formatter fmt = new Formatter();

    fmt.format("%,.2f", 4356783497.34);
    System.out.println(fmt);//ww w. j  a v  a  2 s  . c o  m

}

From source file:MainClass.java

public static void main(String args[]) {
    Formatter fmt = new Formatter();

    fmt.format("%X", 250);
    System.out.println(fmt);//from w  ww  . ja va  2  s . c o m

}

From source file:MainClass.java

public static void main(String args[]) {
    Formatter fmt = new Formatter();

    fmt.format("%#x", 1);
    System.out.println(fmt);/*from   w w  w .j ava2 s  .  c  om*/

}

From source file:MainClass.java

public static void main(String args[]) {
    Formatter fmt = new Formatter();

    fmt.format("%05d", 100);
    System.out.println(fmt);/* w  w  w.  j  av a 2  s  .c  o m*/

}

From source file:MainClass.java

public static void main(String args[]) {
    Formatter fmt = new Formatter();

    fmt.format("%#e", 1F);
    System.out.println(fmt);/*from w w  w. j  av a 2  s  .  c om*/

}

From source file:MainClass.java

public static void main(String args[]) {
    Formatter fmt = new Formatter();

    fmt.format("%#o", 1);
    System.out.println(fmt);/*w ww  .  java  2  s  .c  o  m*/

}