Java Double Number Create toDouble(String value, Double defaultValue)

Here you can find the source of toDouble(String value, Double defaultValue)

Description

to Double

License

Open Source License

Declaration

public static Double toDouble(String value, Double defaultValue) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {

    public static Double toDouble(String value, Double defaultValue) {
        if (isEmpty(value))
            return defaultValue;
        try {//from   www .ja v a2s .  c om
            return Double.parseDouble(value);
        } catch (Exception e) {
            return defaultValue;
        }
    }

    public static boolean isEmpty(String str) {
        if (str == null)
            return true;

        if ("".equals(str.trim()))
            return true;

        return false;
    }
}

Related

  1. toDouble(String value)
  2. toDouble(String value)
  3. toDouble(String value)
  4. toDouble(String value, double defaultValue)
  5. toDouble(String value, double defaultValue)
  6. toDouble(String value, double defaultValue)
  7. toDouble(String value, Double fallback)
  8. toDouble(T value)