Java Utililty Methods BigDecimal Create

List of utility methods to do BigDecimal Create

Description

The list of methods to do BigDecimal Create are organized into topic(s).

Method

BigDecimalgetBdIgnoreNull(BigDecimal bigDecimalPara)
get Bd Ignore Null
return bigDecimalPara == null ? new BigDecimal(0) : bigDecimalPara;
StringgetBigDecimal(BigDecimal bigDecimal)
get Big Decimal
if (bigDecimal == null)
    return "0";
return bigDecimal.toString();
BigDecimalgetBigDecimal(double value, int decimals)
Returns the big decimal for the value and scale.
return new BigDecimal(value).setScale(decimals, BigDecimal.ROUND_HALF_UP);
BigDecimalgetBigDecimal(final String str, final int scale)
This method will return a BigDecimal for a given input string and specified scale.
BigDecimal returnValue;
try {
    returnValue = new BigDecimal(str).setScale(scale, RoundingMode.HALF_UP);
} catch (Exception exception) {
    returnValue = new BigDecimal("0.00");
return returnValue;
BigDecimalgetBigDecimal(JsonObject object, String memberName)
Gets nullable BigDecimal from a JSON object.
JsonPrimitive primitive = getPrimitiveChecked(object, memberName);
return primitive == null ? null : primitive.getAsBigDecimal();
BigDecimalgetBigDecimal(Map map, String attr)
get Big Decimal
return (BigDecimal) map.get(attr);
BigDecimalgetBigDecimal(Number number)
get Big Decimal
BigDecimal bigDecimal = null;
if (number instanceof Byte || number instanceof Short || number instanceof Integer
        || number instanceof Long) {
    bigDecimal = new BigDecimal(number.longValue());
} else if (number instanceof Float || number instanceof Double) {
    bigDecimal = BigDecimal.valueOf(number.doubleValue());
} else if (number instanceof BigInteger) {
    bigDecimal = new BigDecimal((BigInteger) number);
...
BigDecimalgetBigDecimal(Object number)
get Big Decimal
BigDecimal num = null;
if (number instanceof BigDecimal) {
    num = (BigDecimal) number;
} else {
    num = new BigDecimal(number.toString());
return num;
BigDecimalgetBigDecimal(Object o)
get Big Decimal
BigDecimal sh = new BigDecimal(0);
if (null == o)
    return sh;
if (o instanceof Number) {
    Number num = (Number) o;
    sh = new BigDecimal(num.doubleValue());
return sh;
...
BigDecimalgetBigDecimal(Object o)
get Big Decimal
if (o instanceof Number) {
    return new BigDecimal(((Number) o).doubleValue());
return new BigDecimal(o.toString());