Java Double Number Create toDouble(Object obj)

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

Description

to Double

License

Open Source License

Declaration

static Double toDouble(Object obj) 

Method Source Code

//package com.java2s;

public class Main {
    static Double toDouble(Object obj) {
        if (obj instanceof String)
            return Double.valueOf((String) obj);
        if (obj instanceof Byte) {
            Byte b = (Byte) obj;
            return b.doubleValue();
        }//  www .j a v a  2  s.  c om
        if (obj instanceof Short) {
            Short s = (Short) obj;
            return s.doubleValue();
        }
        if (obj instanceof Integer) {
            Integer i = (Integer) obj;
            return i.doubleValue();
        }
        if (obj instanceof Long) {
            Long l = (Long) obj;
            return l.doubleValue();
        }
        if (obj instanceof Float) {
            Float f = (Float) obj;
            return f.doubleValue();
        }
        return (Double) obj;
    }
}

Related

  1. toDouble(Object obj)
  2. toDouble(Object obj)
  3. toDouble(Object obj)
  4. toDouble(Object obj)
  5. toDouble(Object obj)
  6. toDouble(Object obj)
  7. toDouble(Object obj)
  8. toDouble(Object object)
  9. toDouble(Object object, double defaultValue)