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

BigDecimalbigDecimal(Number num)
big Decimal
if (num == null)
    throw new NullPointerException();
if (num instanceof BigDecimal)
    return (BigDecimal) num;
if (num instanceof BigInteger)
    return new BigDecimal((BigInteger) num);
if (num instanceof Byte)
    return new BigDecimal((Byte) num);
...
BigDecimalbigDecimal(Object object)
big Decimal
if (object == null) {
    throw new NullPointerException();
BigDecimal result;
try {
    result = new BigDecimal(String.valueOf(object).replaceAll(",", ""));
} catch (NumberFormatException e) {
    throw new NumberFormatException("Please give me a numeral.Not " + object);
...
BigDecimalbigDecimalFromBytes(byte[] decimalBytes, int scale)
Returns a BigDecimal from the given bytes and scale.
final BigInteger bigInt = new BigInteger(decimalBytes);
return new BigDecimal(bigInt, scale);
java.math.BigDecimalbigDecimalFromString(String s)
big Decimal From String
int len = s.length();
byte[] data = s.getBytes();
int i;
int tickPos = -1;
boolean finishedWithDigits = false;
for (i = 0; i < len; i++) {
    byte b = data[i];
    if ((b == 0 || b == 32) && !finishedWithDigits) {
...
BigDecimalbigDecimalValue(final Number number)
big Decimal Value
if (number == null)
    return null;
if (number instanceof BigDecimal)
    return (BigDecimal) number;
if (number instanceof BigInteger)
    return new BigDecimal((BigInteger) number);
return (number instanceof Double || number instanceof Float) ? BigDecimal.valueOf(number.doubleValue())
        : BigDecimal.valueOf(number.longValue());
...
BigDecimalbigDecimalValueOf(Number n)
Converts a number into its BigDecimal equivalent.
if (n instanceof BigDecimal) {
    return (BigDecimal) n;
} else if (n instanceof BigInteger) {
    return new BigDecimal((BigInteger) n);
} else if (n instanceof Double) {
    return new BigDecimal((Double) n);
} else if (n instanceof Float) {
    return new BigDecimal((Float) n);
...
BigDecimalcreateBigDecimal(double v)
create Big Decimal
return new BigDecimal(Double.toString(v));
BigDecimalcreateBigDecimal(final String value)
This method creates a new big-decimal.
return createBigDecimal(new BigDecimal(value));
BigDecimalcreateBigDecimal(Object value)
create Big Decimal
BigDecimal valueAsBd = null;
if (value instanceof Number) {
    valueAsBd = new BigDecimal(((Number) value).doubleValue());
} else {
    if (value instanceof String) {
        valueAsBd = new BigDecimal((String) value);
    } else {
        valueAsBd = new BigDecimal(value.toString());
...
BigDecimalcreateBigDecimal(String val)

Convert a String to a BigDecimal.

BigDecimal bd = new BigDecimal(val);
return bd;