Java Object to Double asDouble(Object obj)

Here you can find the source of asDouble(Object obj)

Description

as Double

License

Open Source License

Declaration

public static double asDouble(Object obj) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static double asDouble(Object obj, double defvalue) {
        if (obj instanceof Number)
            return ((Number) obj).doubleValue();
        if (obj instanceof String) {
            try {
                return Double.parseDouble((String) obj);
            } catch (NumberFormatException ex) {
                // log?
            }/*from  w  ww.ja va 2  s  .c o m*/
        }
        return defvalue;
    }

    public static double asDouble(Object obj) {
        return asDouble(obj, 0);
    }
}

Related

  1. asDouble(final Object o)
  2. asDouble(final Object object)
  3. asDouble(Object o)
  4. asDouble(Object val, Double def)
  5. asDouble(Object value)
  6. asDouble(Object value)
  7. asDouble(Object value)