Java Long Number Create toLong(Object obj)

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

Description

to Long

License

Open Source License

Declaration

public static long toLong(Object obj) throws Exception 

Method Source Code

//package com.java2s;

public class Main {

    public static long toLong(Object obj) throws Exception {
        return Long.parseLong(toString(obj).trim());
    }/*from ww w  .  j a v a 2s.c om*/

    public static long toLong(Object obj, long defaultValue) {
        try {
            return toLong(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. toLong(Object number)
  2. toLong(Object o)
  3. toLong(Object o)
  4. toLong(Object o)
  5. toLong(Object ob, Long defaultLong)
  6. toLong(Object obj)
  7. toLong(Object obj)
  8. toLong(Object obj)
  9. toLong(Object obj)