DecimalFormat SetRoundingMode() Example
Sets the RoundingMode used in this DecimalFormat.
DecimalFormatclass SetRoundingMode() method example. This example shows you how to use SetRoundingMode() method.This method Sets the RoundingMode used in this DecimalFormat.
Here is the code:-
/**
* @Program that Sets the Rounding Mode used in this DecimalFormat.
* SetRoundingMode.java
* Author:-RoseIndia Team
* Date:-13-Jun-2008
*/
import java.text.*;
import java.math.*;
public class SetRoundingMode {
public static void main(String[] args) {
// Creates a DecimalFormat object
DecimalFormat d = new DecimalFormat("3.65532");
// Get the positive suffix.
System.out.println("The Rounding Mode is: " + d.getRoundingMode());
d.setRoundingMode(RoundingMode.HALF_DOWN );
System.out.println("The Rounding Mode is: "+d.getRoundingMode());
}
} |
Output of the Program
The Rounding Mode is: HALF_EVEN
The Rounding Mode is: HALF_DOWN |
|