public static Double getAsDouble ( Object value ) { Double result = null ; try { if ( value instanceof String ) { result = Double . valueOf ( ( String ) value ) ; } else if ( value instanceof Number ) { result = ( ( Number ) value ) . doubleValue ( ) ; } else { result = null ; } } catch ( Exception e ) { result = null ; } return result == null ? 0 : result ; }
Converts the value parameter to a Double . If the value is null or invalid it returns zero .