Java Long Number Create toLong(String value, Long defaultValue)

Here you can find the source of toLong(String value, Long defaultValue)

Description

to Long

License

Open Source License

Declaration

public static Long toLong(String value, Long defaultValue) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {

    public static Long toLong(String value, Long defaultValue) {
        if (isEmpty(value))
            return defaultValue;
        try {/*w w  w.  ja v a2s .  c o m*/
            return Long.parseLong(value);
        } catch (Exception e) {
            return defaultValue;
        }
    }

    public static boolean isEmpty(String str) {
        if (str == null)
            return true;

        if ("".equals(str.trim()))
            return true;

        return false;
    }
}

Related

  1. toLong(String value)
  2. toLong(String value, long _default)
  3. toLong(String value, long def)
  4. toLong(String value, Long defaultValue)
  5. toLong(String value, long defaultValue)
  6. toLong(T value)
  7. toLongObject(Object o)