NumberFormat.format(long number, StringBuffer toAppendTo, FieldPosition pos) has the following syntax.
public abstract StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos)
In the following code shows how to use NumberFormat.format(long number, StringBuffer toAppendTo, FieldPosition pos) method.
//from w ww . jav a 2 s. c om import java.text.FieldPosition; import java.text.NumberFormat; public class Main { public static void main(String[] args) throws Exception { NumberFormat numberFormat = NumberFormat.getPercentInstance(); StringBuffer sb = new StringBuffer(); numberFormat.format(111L,sb,new FieldPosition(0)); System.out.println(sb); } }
The code above generates the following result.