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

BigDecimalgetBigDecimal(Object v, BigDecimal defaultValue)
get Big Decimal
if (v == null || VALUE_BLANK.equals(v)) {
    return null;
} else if (v instanceof BigDecimal) {
    return (BigDecimal) v;
} else if (v instanceof String) {
    return new BigDecimal((String) v);
} else if (v instanceof Integer) {
    return new BigDecimal((Integer) v);
...
BigDecimalgetBigDecimal(Object value)
get Big Decimal
if (value == null) {
    return null;
try {
    return (new BigDecimal(value.toString().trim()));
} catch (NumberFormatException ex) {
    throw new Exception("bigdecimal conversion failed. (" + value.toString().trim() + ")");
BigDecimalgetBigDecimal(Object value)
get Big Decimal
BigDecimal ret = null;
if (value != null) {
    if (value instanceof BigDecimal) {
        ret = (BigDecimal) value;
    } else if (value instanceof String) {
        ret = new BigDecimal((String) value);
    } else if (value instanceof BigInteger) {
        ret = new BigDecimal((BigInteger) value);
...
BigDecimalgetBigDecimal(String aInput)
get Big Decimal
return getBigDecimal(aInput, BLANK_DECIMAL);
BigDecimalgetBigDecimal(String value)
get Big Decimal
BigDecimal result = null;
if (value != null) {
    try {
        result = BigDecimal.valueOf(Double.valueOf(value));
    } catch (Exception ignored) {
return result;
...
BigDecimal[]getBigDecimalArrayFromByteArray(byte[] buf)
Convert a byte[] into an instance of our value class.
BigDecimal[] a = new BigDecimal[buf.length / TOTAL_BYTES];
int index = 0;
for (int i = 0; i < a.length; i++) {
    byte[] signal = new byte[NR_SIGNAL_BYTES];
    System.arraycopy(buf, index, signal, 0, NR_SIGNAL_BYTES);
    index += NR_SIGNAL_BYTES;
    byte[] b = new byte[NR_BIGINTEGER_BYTES];
    System.arraycopy(buf, index, b, 0, NR_BIGINTEGER_BYTES);
...
BigDecimalgetBigDecimalByObject(Object obj)
Gets the big decimal by object.
if (obj == null) {
    return BigDecimal.valueOf(0.0);
} else {
    BigDecimal result = null;
    try {
        result = new BigDecimal(String.valueOf(obj));
    } catch (Exception ex) {
        result = BigDecimal.valueOf(0.0);
...
BigDecimalgetBigDecimalFrom(double value)
get Big Decimal From
return new BigDecimal(String.valueOf(value));
BigDecimalgetBigDecimalFromByteArray(byte[] bytes, int start, int length, int scale)
get Big Decimal From Byte Array
byte[] value = Arrays.copyOfRange(bytes, start, start + length);
BigInteger unscaledValue = new BigInteger(value);
return new BigDecimal(unscaledValue, scale);
BigDecimalgetBigDecimalFromPrimitiveTypes(int input, int scale, int precision)
get Big Decimal From Primitive Types
return BigDecimal.valueOf(input, scale);