Here you can find the source of toLong(Object obj)
public static long toLong(Object obj)
//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; } }