Here you can find the source of toLong(Object ob, Long defaultLong)
public static Long toLong(Object ob, Long defaultLong)
//package com.java2s; public class Main { public static Long toLong(Object ob, Long defaultLong) { if (ob == null) { return defaultLong; }//from w w w. j a va 2s. co m if (ob instanceof Integer) { return ((Integer) ob).longValue(); } else if (ob instanceof Float) { return ((Float) ob).longValue(); } else if (ob instanceof Double) { return ((Double) ob).longValue(); } else if (ob instanceof Byte) { return ((Byte) ob).longValue(); } else { try { return new Long(ob.toString()); } catch (Exception e) { return defaultLong; } } } public static Long toLong(Object ob) { return toLong(ob, 0l); } }