Java NumberFormat .setRoundingMode (RoundingMode roundingMode)

Syntax

NumberFormat.setRoundingMode(RoundingMode roundingMode) has the following syntax.

public void setRoundingMode(RoundingMode roundingMode)

Example

In the following code shows how to use NumberFormat.setRoundingMode(RoundingMode roundingMode) method.


import java.math.RoundingMode;
import java.text.NumberFormat;
import java.util.Currency;
import java.util.Locale;
//  ww w  .  j a  v  a2 s .co  m
public class Main {
  public static void main(String[] args) throws Exception {
    NumberFormat numberFormat = NumberFormat.getNumberInstance();
    numberFormat.setCurrency(Currency.getInstance(Locale.CANADA));
    numberFormat.setRoundingMode(RoundingMode.CEILING);
    
    
  }
}




















Home »
  Java Tutorial »
    java.text »




DateFormat
DecimalFormat
NumberFormat
SimpleDateFormat