Java Double Number Create toDouble(Object obj)

Here you can find the source of toDouble(Object obj)

Description

to Double

License

Open Source License

Declaration

public static double toDouble(Object obj) throws Exception 

Method Source Code

//package com.java2s;

public class Main {

    public static double toDouble(Object obj) throws Exception {
        return Double.parseDouble(toString(obj).trim());
    }//from  w w w  .j a  v a2  s.com

    public static double toDouble(Object obj, double defaultValue) {
        try {
            return toDouble(obj);
        } catch (Exception ex) {
            return defaultValue;
        }
    }

    public static String toString(double obj) throws Exception {
        return Double.toString(obj);
    }

    public static String toString(double obj, String defaultValue) {
        try {
            return toString(obj);
        } catch (Exception ex) {
            return defaultValue;
        }
    }

    public static String toString(int obj) throws Exception {
        return Integer.toString(obj);
    }

    public static String toString(int obj, String defaultValue) {
        try {
            return toString(obj);
        } catch (Exception ex) {
            return defaultValue;
        }
    }

    public static String toString(long obj) throws Exception {
        return Long.toString(obj);
    }

    public static String toString(long obj, String defaultValue) {
        try {
            return toString(obj);
        } catch (Exception ex) {
            return defaultValue;
        }
    }

    public static String toString(Object obj) throws Exception {
        if (obj == null) {
            return "";
        }
        return String.valueOf(obj);
    }

    public static String toString(Object obj, String defaultValue) {
        try {
            return toString(obj);
        } catch (Exception ex) {
            return defaultValue;
        }
    }
}

Related

  1. toDouble(Object obj)
  2. toDouble(Object obj)
  3. toDouble(Object obj)
  4. toDouble(Object obj)
  5. toDouble(Object obj)
  6. toDouble(Object obj)
  7. toDouble(Object obj)
  8. toDouble(Object obj)
  9. toDouble(Object object)