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(String str)
to Double
try {
    return Double.parseDouble(str);
} catch (Exception e) {
return 0.0d;
doubletoDouble(String str)
toDouble
double dval = 0.0;
if (str == null || str.equalsIgnoreCase("null") || str.equalsIgnoreCase("") || str.equalsIgnoreCase("0"))
    return 0.00;
dval = Double.parseDouble(str.trim());
return dval;
doubletoDouble(String str)
to Double
return Double.parseDouble(str);
doubletoDouble(String str)
to Double
return toDouble(str, 0.0d);
doubletoDouble(String str)

Convert a String to a double, returning 0.0d if the conversion fails.

If the string str is null, 0.0d is returned.

 NumberUtils.toDouble(null)   = 0.0d NumberUtils.toDouble("")     = 0.0d NumberUtils.toDouble("1.5")  = 1.5d 
return toDouble(str, 0.0d);
DoubletoDouble(String str)
to Double
Double rtn = null;
if (str != null) {
    try {
        rtn = new Double(str);
    } catch (NumberFormatException e) {
        rtn = null;
return rtn;
doubletoDouble(String str, double defaultValue)

Convert a String to a double, returning a default value if the conversion fails.

if (str == null) {
    return defaultValue;
try {
    return Double.parseDouble(str);
} catch (NumberFormatException nfe) {
    return defaultValue;
doubletoDouble(String string)
string2Double
String str = trim(string);
if ("".equals(str))
    str = "0.0";
return Double.parseDouble(str);
doubleToDouble(String string)
To Double
try {
    return Double.parseDouble(string);
} catch (NumberFormatException e) {
    return -1;
doubletoDouble(String v, double def)
Converts specified string to double.
if (v == null)
    return def;
try {
    return Double.valueOf(v).doubleValue();
} catch (NumberFormatException e) {
    return def;