Java Long Number Create toLong(Object object)

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

Description

Lenient convertor -- accepts String or any Number subclass.

License

Open Source License

Parameter

Parameter Description
object Can be null (returns 0)

Declaration

public static long toLong(Object object) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//from ww  w .  j a  v  a  2 s  .  co  m
     * Lenient convertor -- accepts String or any Number subclass.
     * @param object Can be null (returns 0)
     */
    public static long toLong(Object object) {
        if (object == null)
            return 0;
        if (object instanceof Number)
            return ((Number) object).longValue();
        return Long.valueOf((String) object);
    }
}

Related

  1. toLong(Object obj)
  2. toLong(Object obj, String pattern)
  3. toLong(Object object)
  4. toLong(Object object)
  5. toLong(Object object)
  6. toLong(Object object, long defaultValue)
  7. toLong(Object object, Long defaultValue)
  8. toLong(Object objectToConvert)
  9. toLong(Object objValue)