Here you can find the source of toBigDecimal(Object value)
public static BigDecimal toBigDecimal(Object value)
//package com.java2s; //License from project: Apache License import java.math.BigDecimal; public class Main { /**/*ww w . j ava 2s . c o m*/ * Convert an Object to a BigDecimal. */ public static BigDecimal toBigDecimal(Object value) { if (value == null) return null; if (value instanceof BigDecimal) return (BigDecimal) value; if (value instanceof String) { if ("".equals((String) value)) return null; return new BigDecimal((String) value); } if (value instanceof Number) return new BigDecimal(((Number) value).doubleValue()); return new BigDecimal(value.toString()); } /** * Convert an Object to a double, or 0 if it is null. */ public static double doubleValue(Object value) { if (value == null) return 0.0; return toDouble(value).doubleValue(); } /** * Convert an Object to a Double. */ public static Double toDouble(Object value) { if (value == null) return null; if (value instanceof Double) return (Double) value; if (value instanceof String) { if ("".equals((String) value)) return null; return new Double((String) value); } if (value instanceof Number) return new Double(((Number) value).doubleValue()); return new Double(value.toString()); } }