Java examples for java.lang:String Parse
Parse Long from String with default value
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { String value = "java2s.com"; System.out.println(getLong(value)); }// w w w . j a v a 2 s . co m public static Long getLong(String value, Long defaultValue) { try { return Long.valueOf(value); } catch (Exception ex) { return defaultValue; } } public static Long getLong(String value) { return getLong(value, null); } }