Java BigDecimal from toBigDecimal(Number num)

Here you can find the source of toBigDecimal(Number num)

Description

to Big Decimal

License

Apache License

Declaration

private static BigDecimal toBigDecimal(Number num) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.math.BigDecimal;

public class Main {
    private static BigDecimal toBigDecimal(Number num) {
        try {//from  ww w  . j a  v a  2  s  .c om
            return num instanceof BigDecimal ? (BigDecimal) num : new BigDecimal(num.toString());
        } catch (NumberFormatException e) {
            // The exception message is useless, so we add a new one:
            throw new NumberFormatException("Can't parse this as BigDecimal number: " + num);
        }
    }
}

Related

  1. toBigDecimal(long seconds, int nanoseconds)
  2. toBigDecimal(Number n)
  3. toBigDecimal(Number n)
  4. toBigDecimal(Number n)
  5. toBigDecimal(Number n)
  6. toBigDecimal(Number number)
  7. toBigDecimal(Number number)
  8. toBigDecimal(Number number)
  9. toBigDecimal(Number number)