Java Utililty Methods Object to Double

List of utility methods to do Object to Double

Description

The list of methods to do Object to Double are organized into topic(s).

Method

DoubleasDouble(final Object o)
as Double
if (o instanceof Number) {
    return ((Number) o).doubleValue();
return null;
DoubleasDouble(final Object object)
return Object value as Double
if (object instanceof String) {
    return Double.parseDouble((String) object);
} else if (object instanceof Number) {
    return ((Number) object).doubleValue();
return Double.NaN;
DoubleasDouble(Object o)
Converts the given object to a Double
if (o instanceof Number) {
    return ((Number) o).doubleValue();
return null;
doubleasDouble(Object obj)
as Double
return asDouble(obj, 0);
DoubleasDouble(Object val, Double def)
as Double
Double ret = null;
try {
    ret = Double.valueOf(val.toString());
} catch (Exception e) {
    ret = def;
return ret;
doubleasDouble(Object value)
as Double
if (value instanceof Double) {
    return ((Double) value).doubleValue();
throw new IllegalArgumentException("not a number");
doubleasDouble(Object value)
as Double
if (value == null) {
    return -1;
} else {
    return Double.parseDouble(value.toString());
doubleasDouble(Object value)
as Double
return Double.valueOf(value.toString());
doublecastDouble(Object o)
cast Double
return Double.valueOf(o.toString());
floatcastDoubleToFloat(final double v)
Safely cast a double to a float.
if (Math.abs(v) > Float.MAX_VALUE) {
    throw new ArithmeticException("casted value is out of the range of float");
return (float) v;