Java String to Double convertStringToDouble(String number)

Here you can find the source of convertStringToDouble(String number)

Description

Return the Double value of the input string.

License

Open Source License

Parameter

Parameter Description
number the number in String type

Return

the number in Double type, return null if the number can not be converted to Double type.

Declaration

public static Double convertStringToDouble(String number) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from  ww  w.ja v a 2 s  . c o m*/
     * <p>
     * Return the Double value of the input string.
     * </p>
     *
     * @param number
     *                  the number in String type
     * @return
     *                  the number in Double type, return null
     *                  if the number can not be converted to Double
     *                  type.
     */
    public static Double convertStringToDouble(String number) {
        if (number == null) {
            return null;
        }
        try {
            return Double.parseDouble(number);
        } catch (NumberFormatException e) {
            return null;
        }
    }
}

Related

  1. atof(String pString_)
  2. atof(String s)
  3. atof(String s)
  4. atof(String s)
  5. convertStringToDouble(String num)
  6. convertStringToDouble(String s)
  7. convertStringToDouble(String valueString)