Java BigDecimal Round roundBigDecimal(BigDecimal num)

Here you can find the source of roundBigDecimal(BigDecimal num)

Description

round Big Decimal

License

Open Source License

Declaration

public static BigDecimal roundBigDecimal(BigDecimal num) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.math.BigDecimal;
import java.math.RoundingMode;

public class Main {
    public static BigDecimal roundBigDecimal(BigDecimal num) {
        return roundBigDecimal(num, 2);
    }/*from   w  w w .ja  v a 2s . c o m*/

    public static BigDecimal roundBigDecimal(BigDecimal num, int scale) {
        if (num != null) {
            return num.setScale(scale, RoundingMode.HALF_UP);
        }
        return num;
    }
}

Related

  1. round(BigDecimal value, String currency)
  2. round(BigDecimal what, int howmuch)
  3. round(final BigDecimal input, final int precision)
  4. round(final BigDecimal number, final int minFractionDigits, final int maxFractionDigits, final RoundingMode roundingMode)
  5. round_BigDecimal(double d, int decLen)
  6. roundBigDecimal(Number value, double precision)
  7. roundCommercial(BigDecimal value, int decimalPlaces)
  8. roundDecimal(Object value)
  9. roundDecimals(Float d)