Java Object to Double castToDouble(Object object)

Here you can find the source of castToDouble(Object object)

Description

Sometimes ELP's version of cast is misbehaving

License

GNU General Public License

Parameter

Parameter Description
object a parameter

Declaration

public static Double castToDouble(Object object) 

Method Source Code

//package com.java2s;
/*/* ww w.  j  a  v  a  2  s .  c  o m*/
 Pulsar
 Copyright (C) 2013-2015 eBay Software Foundation
 Licensed under the GPL v2 license.  See LICENSE for full terms.
 */

public class Main {
    /**
     * Sometimes ELP's version of cast is misbehaving
     * 
     * @param object
     * @return
     */
    public static Double castToDouble(Object object) {
        if (object != null) {
            if (object instanceof Double)
                return (Double) object;
            else
                return Double.valueOf(object.toString());
        }
        return null;
    }
}

Related

  1. asDouble(Object value)
  2. asDouble(Object value)
  3. castDouble(Object o)
  4. castDoubleToFloat(final double v)
  5. castShortToDouble(short[] x)
  6. castToDoubleArray(byte[] data)
  7. castToDoubleArray(Object[] array)
  8. castToDoubles(final int[] ints)
  9. objectToDouble(Object o)