Java Long Number Create toLong(String str)

Here you can find the source of toLong(String str)

Description

to Long

License

Open Source License

Declaration

public static Long toLong(String str) 

Method Source Code

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

public class Main {
    public static Long toLong(String str) {
        if (isEmpty(str))
            return null;
        try {//from w w w. j  a v  a2 s  .c  o m
            return Long.parseLong(str);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    public static Long toLong(String str, Long defaultValue) {
        Long value = toLong(str);
        return value == null ? defaultValue : value;
    }

    public static boolean isEmpty(String str) {
        return !notEmpty(str);
    }

    public static boolean notEmpty(String str) {
        return str != null && str.trim().length() > 0;
    }
}

Related

  1. toLong(String s)
  2. toLong(String s, long defValue)
  3. toLong(String src)
  4. toLong(String str)
  5. toLong(String str)
  6. toLong(String str)
  7. toLong(String str)
  8. toLong(String str)
  9. toLong(String str, long defaultValue)