Java Long Number Create toLong(String str)

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

Description

to Long

License

Apache License

Declaration

public static Long toLong(String str) 

Method Source Code

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

public class Main {

    public static Long toLong(String str) {
        if (str == null || str.length() == 0) {
            return null;
        } else {/*from www  .j a  va  2s. c o m*/
            return Long.parseLong(str);
        }
    }

    public static long toLong(Long num) {
        if (num == null) {
            return 0;
        } else {
            return num.longValue();
        }
    }

    public static long toLong(Double num) {
        if (num == null) {
            return 0;
        } else {
            return num.longValue();
        }
    }

    public static long toLong(Double num, int def) {
        if (num == null) {
            return def;
        } else {
            return num.longValue();
        }
    }
}

Related

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