Java Long Number Parse tryParseLong(Object obj, Long defaultVal)

Here you can find the source of tryParseLong(Object obj, Long defaultVal)

Description

try Parse Long

License

Apache License

Declaration

public static Long tryParseLong(Object obj, Long defaultVal) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static Long tryParseLong(Object obj, Long defaultVal) {
        if (obj == null)
            return defaultVal;
        if (obj instanceof Long)
            return (Long) obj;
        try {/*from w  w w. j  a  v a2 s . c  om*/
            String val = obj.toString();
            return Long.parseLong(val);
        } catch (Exception e) {
            return defaultVal;
        }
    }
}

Related

  1. convertLong(String str, long defaults)
  2. convertLong(String valueAsString)
  3. longFromString(String which, String s)
  4. longFromStringWithoutThrow(String longVal)
  5. tryParseLong(String longString, int defaultValue)
  6. tryParseLong(String longValue)
  7. TryParseLong(String str, long[] n)