Java BigDecimal from numberToBigDecimal(Number value)

Here you can find the source of numberToBigDecimal(Number value)

Description

number To Big Decimal

License

Open Source License

Declaration

public static BigDecimal numberToBigDecimal(Number value) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.math.BigDecimal;

public class Main {
    public static BigDecimal numberToBigDecimal(Number value) {
        if (isAFloatingPointNumber(value)) {
            return new BigDecimal(value.doubleValue());
        } else {/*from w w w.j av a  2  s .  c  om*/
            return new BigDecimal(value.longValue());
        }
    }

    public static boolean isAFloatingPointNumber(Number value) {
        return value instanceof Double || value instanceof Float;
    }
}

Related

  1. doubleToBigDecimal(double amountAsDouble)
  2. doubleToBigDecimal(double dd)
  3. doubleArrayToBigDecimalList( double[] array)
  4. longToBigDecimal(long amountAsSatoshis)
  5. numberToBigDecimal(Number number)
  6. numberToBigDecimal(Object number)
  7. numberToBigDecimal(Object obj)
  8. toBigDecimal(byte[] bytes)
  9. toBigDecimal(Double d)