Here you can find the source of toDouble(Object obj)
public static double toDouble(Object obj)
//package com.java2s; //License from project: Open Source License public class Main { public static double toDouble(Object obj) { return toDouble(obj, 0d); }//from w ww . j av a 2 s. co m 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(); } }