List of usage examples for java.util Formatter Formatter
public Formatter()
From source file:Main.java
public static void main(String[] args) { Formatter formatter = new Formatter(); // format a new string String name = "from java2s.com"; formatter.format("Hello %s !", name); // print the formatted string System.out.println(formatter); // flush the formatter. Here it does nothing. formatter.flush();/* w w w. j a va 2 s. c o m*/ System.out.println("Formatter Flushed."); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Formatter fmt = new Formatter(); Calendar cal = Calendar.getInstance(); fmt.format("Time and date in lowercase: %tc\n", cal); fmt.format("Time and date in uppercase: %Tc\n", cal); System.out.println(fmt);/*from w w w .j ava 2 s . c o m*/ }
From source file:MainClass.java
public static void main(String args[]) { Formatter fmt = new Formatter(); Calendar cal = Calendar.getInstance(); // Display just hour and minute. fmt = new Formatter(); fmt.format("%tl:%tM", cal, cal); System.out.println(fmt);//from ww w . j av a2 s. c o m }
From source file:Main.java
public static void main(String args[]) { Formatter fmt = new Formatter(); Calendar cal = Calendar.getInstance(); fmt = new Formatter(); fmt.format("Default locale: %tc\n", cal); fmt.format(Locale.GERMAN, "For Locale.GERMAN: %tc\n", cal); fmt.format(Locale.ITALY, "For Locale.ITALY: %tc\n", cal); fmt.format(Locale.FRANCE, "For Locale.FRANCE: %tc\n", cal); System.out.println(fmt);// w w w . j a va 2 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);/* www. j a v a 2s.c o m*/ fmt = new Formatter(); fmt.format("% d", 100); System.out.println(fmt); fmt = new Formatter(); fmt.format("% d", -200); System.out.println(fmt); fmt = new Formatter(); fmt.format("% d", 200); System.out.println(fmt); }
From source file:MainClass.java
public static void main(String args[]) { Formatter fmt = new Formatter(); fmt.format("|%f|%n|%12f|%n|%012f|", 10.12345, 10.12345, 10.12345); System.out.println(fmt);/*from w ww . ja v a2s .c om*/ }
From source file:Main.java
public static void main(String args[]) { Formatter fmt;/*from w w w .j a v a2 s . c o m*/ for (int i = 1; i <= 10; i++) { fmt = new Formatter(); fmt.format("%4d %4d %4d", i, i * i, i * i * i); System.out.println(fmt); } }
From source file:MainClass.java
public static void main(String args[]) { Formatter fmt = new Formatter(); Calendar cal = Calendar.getInstance(); // Display month by name and number. fmt = new Formatter(); fmt.format("%tB %tb %tm", cal, cal, cal); System.out.println(fmt);//from w w w .ja va 2s . com }
From source file:MainClass.java
public static void main(String args[]) { Formatter fmt;/*from w w w . j a va 2s . c o m*/ for (int i = 1; i <= 10; i++) { fmt = new Formatter(); fmt.format("%4d %4d %4d", i, i * i, i * i * i); System.out.println(fmt); } }
From source file:MainClass.java
public static void main(String args[]) { Formatter fmt = new Formatter(); fmt.format("Formatting %s is easy %d %f", "with Java", 10, 98.6); System.out.println(fmt);// w w w. j a va2 s . c o m }