Java Double Parse tryParseDouble(Object obj, Double defaultVal)

Here you can find the source of tryParseDouble(Object obj, Double defaultVal)

Description

try Parse Double

License

Apache License

Declaration

public static Double tryParseDouble(Object obj, Double defaultVal) 

Method Source Code

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

public class Main {
    public static Double tryParseDouble(Object obj, Double defaultVal) {
        if (obj == null)
            return defaultVal;
        if (obj instanceof Double)
            return (Double) obj;
        try {//w  w w.j  ava2 s .  c  om
            String val = obj.toString();
            return Double.parseDouble(val);
        } catch (Exception e) {
            return defaultVal;
        }
    }
}

Related

  1. tryParseDouble(Object o)
  2. tryParseDouble(String doubleValue)
  3. tryParseDouble(String value)
  4. tryParseDouble(String value)