DecimalFormat applyLocalizedPattern() Example
Apply the given pattern to this Format object.
DecimalFormatclass applyLocalizedPattern() method example. This example shows you how to use applyLocalizedPattern() method.This method Apply the given pattern to this Format object.
Here is the code:-
/**
* @Program that Apply the given pattern to this Format object.
* ApplyLocalizedPattern.java
* Author:-RoseIndia Team
* Date:-12-Jun-2008
*/
import java.text.*;
public class ApplyLocalizedPattern {
public static void main(String[] args) {
// Creates a DecimalFormat object
DecimalFormat d = new DecimalFormat();
//Apply the given pattern to this Format object.
d.applyLocalizedPattern("#,#00.0#");
// Format decimals using the pattern supplied above.
StringBuffer str = new StringBuffer(24);
FieldPosition pos = new FieldPosition(NumberFormat.FRACTION_FIELD);
str = d.format(22.3423D, str, pos);
System.out.println("String Produced is = " + str);
}
} |
Output of the Program
| String Produced is = 22.34 |
|