Java DecimalFormat .applyLocalizedPattern (String pattern)

Syntax

DecimalFormat.applyLocalizedPattern(String pattern) has the following syntax.

public void applyLocalizedPattern(String pattern)

Example

In the following code shows how to use DecimalFormat.applyLocalizedPattern(String pattern) method.


/*from ww  w . ja  va 2 s. co m*/
import java.text.DecimalFormat;

public class Main {
  public static void main(String[] argv) throws Exception {
    DecimalFormat format = new DecimalFormat();
    format.applyLocalizedPattern("##,##");
    System.out.println(format.format(-123456789.12345678));

  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.text »




DateFormat
DecimalFormat
NumberFormat
SimpleDateFormat