Java Double Number Create toDouble(Object o)

Here you can find the source of toDouble(Object o)

Description

to Double

License

Open Source License

Declaration

public static double toDouble(Object o) 

Method Source Code

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

public class Main {
    public static double toDouble(Object o) {
        if (o instanceof Integer)
            return new Double(((Integer) o).intValue());
        if (o instanceof Double)
            return ((Double) o);
        if (o instanceof String) {
            try {
                return new Double(Double.parseDouble((String) o));
            } catch (NumberFormatException ex) {
                // eat it and drop thru to default return
            }/*w  w  w. j  ava2  s.  co m*/
        }
        return 0.0;
    }
}

Related

  1. toDouble(Object number)
  2. toDouble(Object number)
  3. toDouble(Object o)
  4. toDouble(Object o)
  5. toDouble(Object o)
  6. toDouble(Object o)
  7. toDouble(Object o)
  8. toDouble(Object ob, Double defaultDouble)
  9. toDouble(Object obj)