NumberFormat SetRoundingMode() Example
Sets the RoundingMode used in this NumberFormat.
NumberFormatclass SetRoundingMode() method example. This example shows you how to use SetRoundingMode() method.This method Sets the RoundingMode used in this NumberFormat.
Here is the code:-
/**
* @Program that Sets the RoundingMode used in this NumberFormat.
* SetRoundingMode.java
* Author:-RoseIndia Team
* Date:-17-Jun-2008
*/
import java.text.*;
import java.util.*;
import java.math.*;
public class SetRoundingMode {
public static void main(String[] args) {
//Creating Numberformat instance
NumberFormat nf = NumberFormat.getInstance();
System.out.println("RoundingMode used in this NumberFormat is: "
+nf.getRoundingMode());
nf.setRoundingMode(RoundingMode.FLOOR);
System.out.println("RoundingMode used in this NumberFormat is: "
+nf.getRoundingMode());
}
} |
Output of the program:-
RoundingMode used in this NumberFormat is: HALF_EVEN
RoundingMode used in this NumberFormat is: FLOOR |
|