Here you can find the source of toBigDecimal(Number num)
private static BigDecimal toBigDecimal(Number num)
//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); } } }