Java examples for java.lang:long Parse
Parse String to Long and catch exception
public class Main { public static void main(String[] argv) { String obj = "123"; System.out.println(toLong(obj)); }// ww w .ja va 2s . co m public static long toLong(String obj) { try { return Long.parseLong(obj); } catch (Exception e) { e.printStackTrace(); } return 0; } }