Here you can find the source of castToLong(Object value)
public static final Long castToLong(Object value)
//package com.java2s; //License from project: Apache License public class Main { public static final Long castToLong(Object value) { if (value == null) { return null; }/*w w w . j a v a2 s . c om*/ if (value instanceof Number) { return ((Number) value).longValue(); } if (value instanceof String) { String strVal = (String) value; if (strVal.length() == 0) { return null; } if ("null".equals(strVal) || "NULL".equals(strVal)) { return null; } return Long.parseLong(strVal); } throw new NumberFormatException("can not cast to long, value : " + value); } }