Java Format - 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;
//www . j  a  v a2 s. 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.