Java Utililty Methods String to Double

List of utility methods to do String to Double

Description

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

Method

doubleasDouble(final String str, final double def)
Parse string to double, if string can't be parsed to double, then it will return given default value.
try {
    return Double.parseDouble(str);
} catch (final NumberFormatException e) {
    return def;
doubleasDouble(String str)
as Double
try {
    return Double.valueOf(str);
} catch (NumberFormatException nfex) {
    return Double.NaN;
DoubleasDouble(String string)
Converts string to double
return (string == null) ? null : Double.valueOf(string);
doubleasDouble(String value)
Converts a String value into a double.
return Double.parseDouble(value == null ? value : value.trim());
floatatof(String pString_)
String to float converter.
float fRetVal = 0.0f;
if (isEmpty(pString_)) {
    return fRetVal;
try {
    fRetVal = Float.valueOf(pString_).floatValue();
} catch (NumberFormatException pNumberFormatException) {
    fRetVal = Float.NaN;
...
doubleatof(String s)
atof
double d = Double.valueOf(s).doubleValue();
if (Double.isNaN(d) || Double.isInfinite(d)) {
    System.err.print("NaN or Infinity in input\n");
    System.exit(1);
return (d);
doubleatof(String s)
Returns the double value of s.
int i, numMinuses = 0, numDots = 0;
s = s.trim();
for (i = 0; i < s.length()
        && (s.charAt(i) == '-' || s.charAt(i) == '.' || Character.isDigit(s.charAt(i))); i++)
    if (s.charAt(i) == '-')
        numMinuses++;
    else if (s.charAt(i) == '.')
        numDots++;
...
doubleatof(String s)
atof
if (s == null || s.length() < 1)
    throw new IllegalArgumentException("Can't convert empty string to double");
double d = Double.parseDouble(s);
if (Double.isNaN(d) || Double.isInfinite(d)) {
    throw new IllegalArgumentException("NaN or Infinity in input: " + s);
return (d);
doubleconvertStringToDouble(String num)
convert String To Double
double val = 0;
if (num != null) {
    val = Double.parseDouble(num);
return val;
DoubleconvertStringToDouble(String number)

Return the Double value of the input string.

if (number == null) {
    return null;
try {
    return Double.parseDouble(number);
} catch (NumberFormatException e) {
    return null;