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) 

Method Source Code

//package com.java2s;

public class Main {
    public static long toLong(Object obj) {
        Long i = toLongAsObject(obj);

        if (i != null) {
            return i.longValue();
        }//from   ww w.jav a  2  s .  com

        return 0;
    }

    public static Long toLongAsObject(Object obj) {
        if (obj != null) {
            if (obj instanceof Long) {
                return (Long) obj;
            } else {
                try {
                    return Long.parseLong(String.valueOf(obj));
                } catch (Exception e) {
                }
            }
        }

        return null;
    }
}

Related

  1. toLong(Object obj)
  2. toLong(Object obj)
  3. toLong(Object obj)
  4. toLong(Object obj)
  5. toLong(Object obj)
  6. toLong(Object obj)
  7. toLong(Object obj)
  8. toLong(Object obj)
  9. toLong(Object obj, String pattern)