DecimalFormat.applyPattern(String pattern) has the following syntax.
public void applyPattern(String pattern)
In the following code shows how to use DecimalFormat.applyPattern(String pattern) method.
import java.text.DecimalFormat; //from w ww.ja v a2 s. com public class Main { public static void main(String[] argv) throws Exception { DecimalFormat format = new DecimalFormat(); format.applyPattern("##.##"); System.out.println(format.format(-123456789.12345678)); } }
The code above generates the following result.