Java DecimalFormat .setMinimumFractionDigits (int newValue)

Syntax

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

public void setMinimumFractionDigits(int newValue)

Example

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


import java.text.DecimalFormat;
/*from   w  w w  .jav a  2s .  c  o m*/
public class Main {
  public static void main(String[] argv) throws Exception {
    DecimalFormat format = new DecimalFormat();
    
    format.setMinimumFractionDigits(4);
    
    System.out.println(format.format(123456789.12345678));

  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.text »




DateFormat
DecimalFormat
NumberFormat
SimpleDateFormat