Here you can find the source of toLong(String value, Long defaultValue)
public static Long toLong(String value, Long defaultValue)
//package com.java2s; //License from project: Open Source License public class Main { public static Long toLong(String value, Long defaultValue) { if (isEmpty(value)) return defaultValue; try {/*w w w. ja v a2s . c o m*/ return Long.parseLong(value); } catch (Exception e) { return defaultValue; } } public static boolean isEmpty(String str) { if (str == null) return true; if ("".equals(str.trim())) return true; return false; } }