List of utility methods to do Double Number Create
double | toDouble(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(); |
Double | toDouble(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(); |
double | toDouble(Number value) Turns a Number object into a double primitive. return value == null ? Double.NaN : value.doubleValue();
|
double | toDouble(Object _inStrObj) to Double if (_inStrObj == null || _inStrObj.toString().trim().equals("")) { return 0; } else { return Double.valueOf(_inStrObj.toString()).doubleValue(); |
double | toDouble(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; ... |
double | toDouble(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; ... |
Double | toDouble(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; |
double | toDouble(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 { ... |
double | toDouble(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; |
double | toDouble(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); |