Java Double Number Create toDouble(String value)

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

Description

Converts the specified value string to the Double value.

License

BSD License

Parameter

Parameter Description
value a value string

Exception

Parameter Description
IllegalArgumentException if format error has occured

Return

a Double object

Declaration

static Double toDouble(String value) throws IllegalArgumentException 

Method Source Code

//package com.java2s;
//License from project: BSD License 

public class Main {
    /**/*from   w w  w  .  ja v a 2  s  . co m*/
     * Converts the specified value string to the Double value.
     * If the specified string is null or blank, this method returns null.
     * 
     * @param value a value string
     * @return a {@code Double} object
     * @throws IllegalArgumentException if format error has occured
     */
    static Double toDouble(String value) throws IllegalArgumentException {
        if (value == null || value.equals("")) {
            //the option not specified or a blank value specified
            return null;
        }

        try {
            return Double.parseDouble(value);
        } catch (NumberFormatException e) {
            throw new IllegalArgumentException("invalid boolean value : " + value);
        }
    }
}

Related

  1. toDouble(String v, double def)
  2. toDouble(String val)
  3. toDouble(String value)
  4. toDouble(String value)
  5. toDouble(String value)
  6. toDouble(String value, double defaultValue)
  7. toDouble(String value, double defaultValue)
  8. toDouble(String value, Double defaultValue)
  9. toDouble(String value, double defaultValue)