Java Double Number Create toDouble(Object obj)

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

Description

to Double

License

Apache License

Declaration

public static double toDouble(Object obj) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static double toDouble(Object obj) {
        if (obj instanceof Integer) {
            return ((Integer) obj).doubleValue();
        }//w  w w  . ja  va2s  . c  o  m
        if (obj instanceof Double) {
            return ((Double) obj).doubleValue();
        }
        if (obj instanceof Long) {
            return ((Long) obj).doubleValue();
        }
        if (obj instanceof Short) {
            return ((Short) obj).doubleValue();
        }
        if (obj instanceof Byte) {
            return ((Byte) obj).doubleValue();
        }
        if (obj instanceof Float) {
            return ((Float) obj).doubleValue();
        }

        throw new IllegalArgumentException("can't cast to number " + obj);
    }
}

Related

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