Here you can find the source of toLong(String str, long defaultValue)
public static long toLong(String str, long defaultValue)
//package com.java2s; //License from project: Apache License public class Main { public static long toLong(String str, long defaultValue) { if (str == null) { return defaultValue; }//from w w w . j a v a 2s .c o m try { return Long.parseLong(str); } catch (NumberFormatException nfe) { return defaultValue; } } }