Java Utililty Methods Object to Double

List of utility methods to do Object to Double

Description

The list of methods to do Object to Double are organized into topic(s).

Method

double[]castShortToDouble(short[] x)
cast Short To Double
double[] res = new double[x.length];
for (int i = 0; i < x.length; i++)
    res[i] = x[i];
return res;
DoublecastToDouble(Object object)
Sometimes ELP's version of cast is misbehaving
if (object != null) {
    if (object instanceof Double)
        return (Double) object;
    else
        return Double.valueOf(object.toString());
return null;
double[]castToDoubleArray(byte[] data)
Convenience method for creating a double array from a byte array.
double[] result = new double[data.length];
for (int i = 0; i < result.length; i++) {
    result[i] = data[i];
return result;
Double[]castToDoubleArray(Object[] array)
EPL has embedded cast method, but it doesn't cover arrays
if (array != null) {
    Double[] retArray = new Double[array.length];
    int i = 0;
    for (Object element : array) {
        retArray[i] = element == null ? null : (Double) element;
        i++;
    return retArray;
...
double[]castToDoubles(final int[] ints)
cast To Doubles
final double[] doubles = new double[ints.length];
for (int i = 0; i < ints.length; ++i)
    doubles[i] = ints[i];
return doubles;
DoubleobjectToDouble(Object o)
object To Double
if (o == null) {
    return null;
if (o instanceof Double) {
    return (Double) o;
if (o instanceof Number) {
    return new Double(((Number) o).doubleValue());
...
DoubleobjectToDouble(Object o)
Convert an object to a Double.
if (o == null) {
    return null;
if (o instanceof Double) {
    return (Double) o;
try {
    return Double.valueOf(o.toString());
...
doubleobjectToDouble(Object o)
object To Double
if (o instanceof Number)
    return ((Number) o).doubleValue();
try {
    if (o == null)
        return -1D;
    else
        return Double.parseDouble(o.toString());
} catch (NumberFormatException e) {
...
doubleobjectToDouble(Object Obj)
object To Double
String Str = Obj.toString();
double NumDouble = Double.valueOf(Str).doubleValue();
return NumDouble;
doubleobjectToDouble(Object obj)
object To Double
return objectToDouble(obj, 0f);