Android String to Double Convert getDouble(String str, double defaultValue)

Here you can find the source of getDouble(String str, double defaultValue)

Description

get Double

Parameter

Parameter Description
str a parameter
defaultValue a parameter

Declaration

public static double getDouble(String str, double defaultValue) 

Method Source Code

//package com.java2s;

public class Main {
    /**//  w w  w  . ja  va2s . c om
     * @param str
     * @param defaultValue
     * @return
     */
    public static double getDouble(String str, double defaultValue) {
        if (str == null)
            return defaultValue;
        try {
            return Double.parseDouble(str);
        } catch (Exception e) {
            return defaultValue;
        }
    }
}

Related

  1. transformToDigit(String numString)
  2. getDoubleFromStr(String str)
  3. getDoubleValue(String value)
  4. parseDistance(double distance)
  5. parseDouble(String string, double defValue)