Java BigDecimal Round getStringValue(BigDecimal val, int newScale, int roundingMode)

Here you can find the source of getStringValue(BigDecimal val, int newScale, int roundingMode)

Description

get String Value

License

Open Source License

Declaration

public static String getStringValue(BigDecimal val, int newScale, int roundingMode) 

Method Source Code


//package com.java2s;

import java.math.BigDecimal;

public class Main {
    public static String getStringValue(BigDecimal val, int newScale, int roundingMode) {
        if (val.compareTo(new BigDecimal(val.intValue())) == 0) {
            val = val.setScale(0);
        } else {/*from   ww  w .  ja  v  a2s  .  c  om*/
            val = val.setScale(newScale, roundingMode);
        }
        return "" + val;
    }
}

Related

  1. decimalRound(BigDecimal number, int numDigits, RoundingMode rounding)
  2. getEfficientRound(BigDecimal val, int effectiveDigit)
  3. getRoundedAmt(BigDecimal amtBeforeRnd)
  4. getRoundedBigDecimal(double value)
  5. getRoundedBigDecimal(double value, int scale)
  6. magicRound(BigDecimal value)
  7. round(BigDecimal amount)
  8. round(BigDecimal aValue, int aScale)
  9. round(BigDecimal b, int precision)