Java BigDecimal Round round(BigDecimal money, int scale)

Here you can find the source of round(BigDecimal money, int scale)

Description

round

License

Apache License

Declaration

public static BigDecimal round(BigDecimal money, int scale) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.math.BigDecimal;

public class Main {

    public static BigDecimal round(BigDecimal money, int scale) {
        if (scale < 0) {
            throw new IllegalArgumentException("The   scale   must   be   a   positive   integer   or   zero");
        }/* w ww  .  ja v a2  s .c o m*/
        BigDecimal one = new BigDecimal("1");
        return money.divide(one, scale, BigDecimal.ROUND_HALF_UP);
    }
}

Related

  1. round(BigDecimal decimal)
  2. round(BigDecimal decimal, int decimalDigits)
  3. round(BigDecimal decimal, int precision)
  4. round(BigDecimal dividend, int divisor)
  5. round(BigDecimal initData, int scale)
  6. round(BigDecimal num, int scale)
  7. round(BigDecimal number)
  8. round(BigDecimal v, int scale, int roundingMode)
  9. round(BigDecimal value)