Android String to Long Convert parseLongWithDefault(String s, long defValue)

Here you can find the source of parseLongWithDefault(String s, long defValue)

Description

parse Long With Default

License

Open Source License

Declaration

public static long parseLongWithDefault(String s, long defValue) 

Method Source Code

//package com.java2s;

public class Main {
    public static long parseLongWithDefault(String s, long defValue) {
        if (s == null) {
            return defValue;
        }/* w w w  .  j  a v  a2s  .  c o m*/

        try {
            return Long.parseLong(s);
        } catch (NumberFormatException e) {
            return defValue;
        }
    }

    public static Long parseLong(String s) {
        try {
            return new Long(s);
        } catch (NumberFormatException e) {
            return null;
        }
    }
}

Related

  1. convertStringToLong(String str, long failValue)
  2. stringToLong(String input)
  3. longsToString(long... longs)
  4. parseCSLongs(String s)
  5. parseLong(String s)
  6. parseLong(String s, long iDefault)
  7. safeParseLong(String number, long fallback)