Java tutorial
//package com.java2s; public class Main { public static Double doubleFromStringOrDouble(Object stringOrDouble) { if (stringOrDouble == null) { return 0.0; } else if (stringOrDouble instanceof String) { try { return Double.parseDouble((String) stringOrDouble); } catch (Exception e) { return 0.0; } } else if (stringOrDouble instanceof Double) { return (Double) stringOrDouble; } else { return 0.0; } } }