Here you can find the source of toLong(String value, long def)
Parameter | Description |
---|---|
value | a parameter |
def | default value |
public static long toLong(String value, long def)
//package com.java2s; //License from project: Apache License public class Main { /**/* ww w .j a v a 2 s . c om*/ * Convert String to long * @param value * @param def default value * @return */ public static long toLong(String value, long def) { if (isEmpty(value)) { return def; } try { return Long.valueOf(value); } catch (NumberFormatException e) { e.printStackTrace(); return def; } } public static boolean isEmpty(String value) { return value == null || "".equals(value); } }