How to use Java Format Specifier?

import java.util.Calendar;

import java.util.Formatter;


public class Main {

  public static void main(String args[]) {

    Formatter fmt = new Formatter();


    fmt = new Formatter();

    System.out.println(fmt.format("%s gap filler %d %f", "Astring", 10, 12.3)); 




You can obtain a reference to the underlying output buffer by calling out(). It returns a reference to an Appendable object.


The code above generates the following result.


Astring gap filler 10 12.300000