Android Utililty Methods String to Double Convert

List of utility methods to do String to Double Convert

Description

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

Method

doubletransformToDigit(String numString)
transform To Digit
return Double.valueOf(numString).doubleValue();
doublegetDouble(String str, double defaultValue)
get Double
if (str == null)
    return defaultValue;
try {
    return Double.parseDouble(str);
} catch (Exception e) {
    return defaultValue;
DoublegetDoubleFromStr(String str)
get Double From Str
Double i = 0.0;
try {
    i = Double.valueOf(str);
} catch (Exception e) {
return i;
DoublegetDoubleValue(String value)
Get Double value
if (isBlank(value)) {
    throw new NumberFormatException();
return Double.parseDouble(value.replaceAll(",", "."));
StringparseDistance(double distance)
parse Distance
DecimalFormat df = new DecimalFormat("#.##");
return df.format(distance) + " km";
doubleparseDouble(String string, double defValue)
Parse string to boule
try {
    return Double.parseDouble(string);
} catch (NumberFormatException nfe) {
    return defValue;
doubletoDouble(String s)
to Double
double i = 0;
try {
    i = Double.parseDouble(s);
} catch (Exception e) {
    i = -1;
return i;