Here you can find the source of toLong(String str)
public static long toLong(String str)
//package com.java2s; /**// ww w . jav a 2s . c o m * KTH Developed by Java * * @Copyright 2011 by Service Platform Development Team, KTH, Inc. All rights reserved. * * This software is the confidential and proprietary information of KTH, Inc. * You shall not disclose such Confidential Information and shall use it only * in accordance with the terms of the license agreement you entered into with KTH. */ public class Main { public static long toLong(String str) { return toLong(str, 0L); } public static long toLong(String str, long defaultValue) { if (str == null) { return defaultValue; } try { return Long.parseLong(str); } catch (Exception e) { return defaultValue; } } public static long toLong(Object obj) { return toLong(obj, 0L); } public static long toLong(Object obj, long defaultValue) { if (obj == null) { return defaultValue; } try { return (Long) obj; } catch (Exception nfe) { return defaultValue; } } }