List of utility methods to do BigDecimal Create
BigDecimal | getBdIgnoreNull(BigDecimal bigDecimalPara) get Bd Ignore Null return bigDecimalPara == null ? new BigDecimal(0) : bigDecimalPara; |
String | getBigDecimal(BigDecimal bigDecimal) get Big Decimal if (bigDecimal == null) return "0"; return bigDecimal.toString(); |
BigDecimal | getBigDecimal(double value, int decimals) Returns the big decimal for the value and scale. return new BigDecimal(value).setScale(decimals, BigDecimal.ROUND_HALF_UP); |
BigDecimal | getBigDecimal(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; |
BigDecimal | getBigDecimal(JsonObject object, String memberName) Gets nullable BigDecimal from a JSON object. JsonPrimitive primitive = getPrimitiveChecked(object, memberName);
return primitive == null ? null : primitive.getAsBigDecimal();
|
BigDecimal | getBigDecimal(Map map, String attr) get Big Decimal return (BigDecimal) map.get(attr);
|
BigDecimal | getBigDecimal(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); ... |
BigDecimal | getBigDecimal(Object number) get Big Decimal BigDecimal num = null; if (number instanceof BigDecimal) { num = (BigDecimal) number; } else { num = new BigDecimal(number.toString()); return num; |
BigDecimal | getBigDecimal(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; ... |
BigDecimal | getBigDecimal(Object o) get Big Decimal if (o instanceof Number) { return new BigDecimal(((Number) o).doubleValue()); return new BigDecimal(o.toString()); |