Here you can find the source of getLongValue(String value, Long defaultValue)
Parameter | Description |
---|---|
value | the string value. |
defaultValue | the default value. |
public static Long getLongValue(String value, Long defaultValue)
//package com.java2s; public class Main { /**/*from w ww .ja va 2 s . c o m*/ * Gets the long value from string. * * @param value the string value. * @param defaultValue the default value. * @return the parsed long value, otherwise defaultValue. */ public static Long getLongValue(String value, Long defaultValue) { try { if (value != null && value.length() > 0) { return Long.parseLong(value); } } catch (NumberFormatException e) { // do nothing } return defaultValue; } }