Formatter.format(Locale l, String format, Object ... args) has the following syntax.
public Formatter format(Locale l, String format, Object ... args)
In the following code shows how to use Formatter.format(Locale l, String format, Object ... args) method.
import java.util.Formatter; import java.util.Locale; //from w w w . java 2 s .co m public class Main { public static void main(String[] args) { StringBuffer buffer = new StringBuffer(); Formatter formatter = new Formatter(buffer, Locale.US); // format a new string String name = "from java2s.com"; formatter.format(Locale.US,"Hello %s !", name); // print the formatted string with specified locale System.out.println(formatter + " " + formatter.locale()); } }
The code above generates the following result.