Android Utililty Methods String to Long Convert

List of utility methods to do String to Long Convert

Description

The list of methods to do String to Long Convert are organized into topic(s).

Method

longparseLong(String s)
parse Long
try {
    return Long.parseLong(s);
} catch (NumberFormatException e) {
    return 0;
LonggetLongValue(String value, Long defaultValue)
Gets the long value from string.
try {
    if (value != null && value.length() > 0) {
        return Long.parseLong(value);
} catch (NumberFormatException e) {
return defaultValue;
longtoLong(String obj)
to Long
try {
    return Long.parseLong(obj);
} catch (Exception e) {
return 0;
booleanisLong(String str)
is Long
if ("0".equals(str.trim())) {
    return true;
Pattern pattern = Pattern.compile("^[^0]\\d*");
Matcher isNum = pattern.matcher(str);
if (!isNum.matches()) {
    return false;
return true;
longgetLongValue(String str)
get Long Value
if (str != null && str.length() > 0) {
    try {
        return Long.parseLong(str);
    } catch (Exception e) {
return 0;
ListstringToListLong(String input)
string To List Long
List<Long> outList = new ArrayList<Long>();
if (null == input || input.trim().isEmpty()) {
    return outList;
String[] out = input.split(COMMA);
for (String temp : out) {
    outList.add(Long.parseLong(temp));
return outList;
longtoLong(String value)
to Long
try {
    return Long.parseLong(value);
} catch (Exception e) {
    Debug.warning(e);
return 0;
longtoLong(String str, long defValue)
to Long
try {
    return Long.parseLong(str);
} catch (Exception e) {
return defValue;
longparseLong(String string, long defValue)
Parse String to long
try {
    return Long.parseLong(string);
} catch (NumberFormatException nfe) {
    return defValue;
longconvertStringToLong(String str, long failValue)
convert String To Long
if (str == null) {
    return failValue;
try {
    return Long.parseLong(str);
} catch (Exception e) {
    e.printStackTrace();
return failValue;