Here you can find the source of toBigDecimal(Object value)
public static BigDecimal toBigDecimal(Object value)
//package com.java2s; //License from project: Open Source License import java.math.BigDecimal; public class Main { public static BigDecimal toBigDecimal(Object value) { return toBigDecimal(value, new BigDecimal(0)); }/* ww w. j a v a 2 s .c o m*/ public static BigDecimal toBigDecimal(Object value, BigDecimal defaultValue) { if (value == null) { return defaultValue; } if (value instanceof BigDecimal) { BigDecimal decimal = (BigDecimal) value; return decimal; } return new BigDecimal(toDouble(value)); } public static double toDouble(Object obj) { return toDouble(obj, 0d); } public static double toDouble(Object obj, double defaultValue) { if (obj == null) { return defaultValue; } if (obj instanceof Number) { Number number = (Number) obj; return number.doubleValue(); } String value = toString(obj); try { return Double.parseDouble(value); } catch (Exception e) { } return defaultValue; } public static String toString(Object value) { if (value == null) { return ""; } return value.toString().trim(); } }