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

BigDecimalnullToZero(BigDecimal decimal)
Convert null decimal to zero.
return decimal == null ? BigDecimal.ZERO : decimal;
BigDecimalnullToZero(BigDecimal num)
null To Zero
if (num == null) {
    return new BigDecimal("0");
return num;
BigDecimaltoBig(Object o)
to Big
if (o == null || o.toString().equals("") || o.toString().equals("NaN")) {
    return new BigDecimal(0);
return new BigDecimal(o.toString());
BigDecimaltoBigDecimal(final Object o)
to Big Decimal
return toBigDecimal(o, null);
BigDecimaltoBigDecimal(final Object value)
to Big Decimal
try {
    final Number number = toNumber(value);
    return new BigDecimal(number.toString());
} catch (Throwable ignored) {
return BigDecimal.ZERO;
BigDecimaltoBigDecimal(Object o)
to Big Decimal
if (o == null) {
    return null;
BigDecimal bigDecimal;
if (o instanceof Byte) {
    bigDecimal = BigDecimal.valueOf((Byte) o);
} else if (o instanceof Short) {
    bigDecimal = BigDecimal.valueOf((Short) o);
...
BigDecimaltoBigDecimal(Object obj)
to Big Decimal
return toBigDecimal(obj, null);
BigDecimaltoBigDecimal(String bigDecimal)
Wandelt einen BigDecimal im AT Format in einen BigDecimal um
return toBigDecimal(bigDecimal, new Locale("de", "AT"));
BigDecimaltoBigDecimal(String text)
Convertesc un string in BigDecimal
if (isValidNumber(text)) {
    ParsePosition p = new ParsePosition(0);
    Number number = getDecimalFormatter(formaterScale).parse(text, p);
    return new BigDecimal(number.toString());
} else
    return null;
NumbertoBigNumber(Number n)
Converts the the Number n to either a BigInteger or a BigDecimal , unless the Number is a Float/Double +/- Infinity or NaN, in which case Double#NaN , Double#POSITIVE_INFINITY , or Double#NEGATIVE_INFINITY is returned.
if (n instanceof BigDecimal || n instanceof BigInteger) {
    return n;
if (n instanceof Float) {
    if (((Float) n).isInfinite()) {
        return n.equals(Float.POSITIVE_INFINITY) ? Double.POSITIVE_INFINITY : Double.NEGATIVE_INFINITY;
    } else if (((Float) n).isNaN()) {
        return Double.NaN;
...