Java Utililty Methods Long Number Parse

List of utility methods to do Long Number Parse

Description

The list of methods to do Long Number Parse are organized into topic(s).

Method

longconvertLong(String str, long defaults)
convert Long
if (str == null) {
    return defaults;
try {
    return Long.parseLong(str);
} catch (Exception e) {
    return defaults;
LongconvertLong(String valueAsString)
convert Long
return Long.valueOf(valueAsString);
longlongFromString(String which, String s)
long From String
try {
    return Long.parseLong(s);
} catch (NumberFormatException e) {
    throw new IllegalArgumentException(String.format("%s must be an integer", which), e);
longlongFromStringWithoutThrow(String longVal)
long From String Without Throw
long toReturn = Long.MIN_VALUE;
try {
    toReturn = Long.parseLong(longVal);
} catch (NumberFormatException ignore) {
return toReturn;
LongtryParseLong(Object obj, Long defaultVal)
try Parse Long
if (obj == null)
    return defaultVal;
if (obj instanceof Long)
    return (Long) obj;
try {
    String val = obj.toString();
    return Long.parseLong(val);
} catch (Exception e) {
...
longtryParseLong(String longString, int defaultValue)
Try to parse long string, returning -1 if it fails.
try {
    return Long.parseLong(longString);
} catch (NumberFormatException e) {
    return defaultValue;
ObjecttryParseLong(String longValue)
try Parse Long
Object parsedValue;
try {
    parsedValue = Long.parseLong(longValue);
} catch (NumberFormatException nfe) {
    parsedValue = longValue;
return parsedValue;
booleanTryParseLong(String str, long[] n)
Try Parse Long
try {
    n[0] = Long.parseLong(str);
    return true;
} catch (Exception e) {
    return false;