Java Long Number Create toLong(Object val)

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

Description

to Long

License

Apache License

Declaration

public static Long toLong(Object val) 

Method Source Code

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

public class Main {

    public static Long toLong(Object val) {
        return toDouble(val).longValue();
    }// w w  w.  java2  s.c  o  m

    public static Double toDouble(Object val) {
        if (val == null) {
            return 0D;
        }
        try {
            return Double.valueOf(trim(val.toString()));
        } catch (Exception e) {
            return 0D;
        }
    }

    public static String trim(String str) {
        return (null == str) ? null : str.trim();
    }
}

Related

  1. toLong(Object object, long defaultValue)
  2. toLong(Object objectToConvert)
  3. toLong(Object objValue)
  4. toLong(Object oid)
  5. toLong(Object property, long defaultValue)
  6. toLong(Object value)
  7. toLong(Object value)
  8. toLong(Object value)
  9. toLong(Object value)