NumberFormat Format4() Example
Formats a number and appends the resulting text to the given string buffer.
NumberFormatclass Format4() method example. This example shows you how to use Format4() method.This method Formats a number and appends the resulting text to the given string buffer.
Here is the code:-
/**
* @Program that Formats a number and appends the resulting text to the given
* string buffer.
* Format4.java
* Author:-RoseIndia Team
* Date:-17-Jun-2008
*/
import java.text.*;
public class Format4 {
public static void main(String[] args) {
//Creating Numberformat instance
NumberFormat nf = NumberFormat.getInstance();
StringBuffer sb=new StringBuffer("Girish");
FieldPosition fp=new FieldPosition(2);
Object n=123456;
System.out.println("The resulting text is: "+nf.format(n, sb, fp));
}
} |
Output of the program:-
| The resulting text is: Girish123,456 |
|