Java Utililty Methods Double Number Create

List of utility methods to do Double Number Create

Description

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

Method

doubletoDouble(Number number)
to overcome Exception occur when Integer, Double or other Number object is null when try to do mathematics operation (+-/*)
if (number == null)
    return 0;
return number.doubleValue();
DoubletoDouble(Number value)
to Double
if (value == null) {
    return null;
} else if (value instanceof Float) {
    String strValue = value.toString();
    return new Double(strValue);
} else {
    return value.doubleValue();
doubletoDouble(Number value)
Turns a Number object into a double primitive.
return value == null ? Double.NaN : value.doubleValue();
doubletoDouble(Object _inStrObj)
to Double
if (_inStrObj == null || _inStrObj.toString().trim().equals("")) {
    return 0;
} else {
    return Double.valueOf(_inStrObj.toString()).doubleValue();
doubletoDouble(Object _value, double _default)
to Double
if (_value == null)
    return _default;
else if (_value instanceof Integer)
    return ((Integer) _value).doubleValue();
else if (_value instanceof Long)
    return ((Long) _value).doubleValue();
else if (_value instanceof Double)
    return (Double) _value;
...
doubletoDouble(Object argSource)
Use this method to convert any Number object to a double.
double ret = Double.NaN;
Class argClass = argSource.getClass();
if (argClass == Byte.class) {
    Byte val = (Byte) argSource;
    ret = val.doubleValue();
if (argClass == Short.class) {
    Short val = (Short) argSource;
...
DoubletoDouble(Object literal)
to Double
if (literal instanceof Number) {
    return ((Number) literal).doubleValue();
if (literal instanceof String) {
    try {
        return Double.valueOf((String) literal);
    } catch (NumberFormatException e) {
return null;
doubletoDouble(Object number)
to Double
if (number == null) {
    return 0.0D;
} else if (number instanceof Number) {
    return ((Number) number).doubleValue();
} else if (number instanceof String) {
    String str = (String) number;
    return isNumeric(str) > 0 ? Double.valueOf(str) : 0.0D;
} else {
...
doubletoDouble(Object number)
to Double
double value = 0f;
if (number instanceof Number) {
    if (number instanceof Long) {
        value += (long) number;
    if (number instanceof Integer) {
        value += (int) number;
    if (number instanceof Float) {
        value += (float) number;
return value;
doubletoDouble(Object o)
to Double
if (o instanceof Double)
    return (Double) o;
if (o instanceof Integer)
    return (double) ((Integer) o);
throw new RuntimeException("Can't convert to double: " + o);