List of usage examples for java.util Formatter format
public Formatter format(String format, Object... args)
From source file:MainClass.java
public static void main(String args[]) { Formatter fmt = new Formatter(); for (double i = 1000; i < 1.0e+10; i *= 100) { fmt.format("%g ", i); System.out.println(fmt);/*ww w . j ava2s .co m*/ } }
From source file:Main.java
public static void main(String[] args) { StringBuffer buffer = new StringBuffer(); Formatter formatter = new Formatter(buffer, Locale.US); String name = "from java2s.com"; formatter.format("Hello %s !", name); System.out.println(formatter.ioException()); }
From source file:MainClass.java
public static void main(String args[]) { Formatter fmt = new Formatter(); Calendar cal = Calendar.getInstance(); fmt.format("%tr", cal); System.out.println(fmt);//from www .ja va 2 s . co m fmt = new Formatter(); fmt.format("%tc", cal); System.out.println(fmt); fmt = new Formatter(); fmt.format("%tl:%tM", cal, cal); System.out.println(fmt); fmt = new Formatter(); fmt.format("%tB %tb %tm", cal, cal, cal); System.out.println(fmt); }
From source file:MainClass.java
public static void main(String args[]) { Formatter fmt = new Formatter(); Calendar cal = Calendar.getInstance(); fmt = new Formatter(); fmt.format("%h", cal); System.out.println(fmt);//from ww w .j a va2 s .co m }
From source file:MainClass.java
public static void main(String args[]) { Formatter fmt = new Formatter(); Calendar cal = Calendar.getInstance(); fmt = new Formatter(); fmt.format("%tc", cal); System.out.println(fmt);/* w w w .ja va 2s .c o m*/ }
From source file:MainClass.java
public static void main(String args[]) { Formatter fmt = new Formatter(); // Display at most 15 characters in a string. fmt = new Formatter(); fmt.format("%.15s", "Formatting with Java is now easy."); System.out.println(fmt);/*from ww w .jav a 2 s .c om*/ }
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);//from w w w .j a v a 2 s . c o m }
From source file:Main.java
public static void main(String[] argv) throws Exception { Formatter fmt = new Formatter(); Calendar cal = Calendar.getInstance(); // Display 12-hour time format. fmt.format("Time using 12-hour clock: %tr\n", cal); System.out.println(fmt);//from ww w . j a v a2 s . c om }
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();// ww w. j a va 2s. c om System.out.println("Formatter Flushed."); }
From source file:MainClass.java
public static void main(String args[]) { Formatter fmt = new Formatter(); // Format to 2 decimal places in a 16 character field. fmt = new Formatter(); fmt.format("%16.2e", 123.1234567); System.out.println(fmt);/*from ww w. j a v a2 s . c o m*/ }