DecimalFormat SetMinimumFractionDigits() Example
Sets the minimum number of digits allowed in the fraction
DecimalFormatclass SetMinimumFractionDigits() method example. This example shows you how to use SetMinimumFractionDigits() method.This method Sets the minimum number of digits allowed in the fraction portion of a number.
Here is the code:-
/**
* @Program that Sets the minimum number of digits allowed in the fraction
* portion of a number.
* SetMinimumFractionDigits.java
* Author:-RoseIndia Team
* Date:-12-Jun-2008
*/
import java.text.*;
public class SetMinimumFractionDigits {
public static void main(String[] args) {
// Creates a DecimalFormat object
DecimalFormat d = new DecimalFormat();
//Gets the minimum number of digits allowed in the fraction sportion of a number.
System.out.println("The minimum number of digits allowed in the fraction portion of a number is: "
+ d.getMinimumFractionDigits());
//Sets the minimum number of digits allowed in the fraction portion of a number.
d.setMinimumFractionDigits(9);
System.out.println("The minimum number of digits allowed in the fraction portion of a number is: "
+ d.getMinimumFractionDigits());
}
} |
Output of the Program
The minimum number of digits allowed in the fraction portion of a number is: 0
The minimum number of digits allowed in the fraction portion of a number is: 9 |
|