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 val)
to Double
Double l = 0.0;
boolean dig = false;
long len = 10;
long digs = 0;
for (char c : val.toCharArray()) {
    if (Character.isDigit(c)) {
        if (dig) {
            digs = digs * 10 + c - 48;
...
DoubletoDouble(String value)
to Double
if (null == value) {
    return null;
value = value.trim();
if ("null".equals(value)) {
    return null;
return Double.parseDouble(value);
...
doubletoDouble(String value)
Extends the Double#valueOf(String) method, in removing the leading and trailing whitespace.
if (value == null) {
    return Double.NaN;
value = value.trim();
return Double.parseDouble(value);
doubletoDouble(String value)
Gets the double value of the input string value.
try {
    value = value.replaceAll("[\\s+ \\$]", "");
    if (value != null) {
        return Double.parseDouble(value);
} catch (Exception ex) {
return 0;
...
DoubletoDouble(String value)
Converts the specified value string to the Double value.
if (value == null || value.equals("")) {
    return null;
try {
    return Double.parseDouble(value);
} catch (NumberFormatException e) {
    throw new IllegalArgumentException("invalid boolean value : " + value);
doubletoDouble(String value, double defaultValue)
Returns the given String parsed to a Double.
try {
    return Double.parseDouble(value);
} catch (NumberFormatException e) {
    return defaultValue;
doubletoDouble(String value, double defaultValue)
convert the string to an double, and return the default value if the string is null or does not contain a valid int value
if (value != null) {
    try {
        return Double.parseDouble(value);
    } catch (NumberFormatException n) {
return defaultValue;
doubletoDouble(String value, double defaultValue)
to Double
if (isNullOrEmpty(value))
    return defaultValue;
try {
    return Double.parseDouble(value.trim());
} catch (NumberFormatException ex) {
    return defaultValue;
DoubletoDouble(String value, Double defaultValue)
to Double
if (isEmpty(value))
    return defaultValue;
try {
    return Double.parseDouble(value);
} catch (Exception e) {
    return defaultValue;
DoubletoDouble(String value, Double fallback)
to Double
if (value == null || value.isEmpty()) {
    return fallback;
try {
    return Double.valueOf(value);
} catch (Exception e) {
    return fallback;