Java DecimalFormat .setGroupingSize (int newValue)

Syntax

DecimalFormat.setGroupingSize(int newValue) has the following syntax.

public void setGroupingSize(int newValue)

Example

In the following code shows how to use DecimalFormat.setGroupingSize(int newValue) method.


import java.text.DecimalFormat;
//from   www.  java2s. c o m
public class Main {
  public static void main(String[] argv) throws Exception {
    DecimalFormat format = new DecimalFormat();
    
    format.setGroupingSize(4);
    
    System.out.println(format.format(123456789.12345678));

  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.text »




DateFormat
DecimalFormat
NumberFormat
SimpleDateFormat