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