Example usage for java.lang Long parseLong

List of usage examples for java.lang Long parseLong

Introduction

In this page you can find the example usage for java.lang Long parseLong.

Prototype

public static long parseLong(String s) throws NumberFormatException 

Source Link

Document

Parses the string argument as a signed decimal long .

Usage

From source file:Main.java

public static String getCommonTimeByStamp(String stamp) {
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    long stampL = Long.parseLong(stamp);
    String d = format.format(new Date(stampL));
    return d;//from w w w .ja  v  a2s  . c o m
}

From source file:Main.java

public static List<Long> stringConvertLong(String[] arry) {
    List<Long> result = new ArrayList<Long>();
    for (String a : arry) {
        result.add(Long.parseLong(a));
    }/*  w  ww . j  a v a2 s . c om*/
    return result;
}

From source file:Main.java

public static List<Long> changeList(String[] ss) {
    List<Long> list = new ArrayList<Long>();
    for (int i = 0; i < ss.length; i++) {
        list.add(Long.parseLong(ss[i]));

    }/*  ww  w  . j  a  va 2 s .co m*/
    return list;
}

From source file:Main.java

@SuppressLint("SimpleDateFormat")
public static String dateFormat(String dateTime) {
    Date date = new Date(Long.parseLong(dateTime));
    SimpleDateFormat myFormat = new SimpleDateFormat("yyyy-MM-dd");
    String time = myFormat.format(date);
    return time;//from  w w w  .  j a v a2  s  .com
}

From source file:Main.java

public static List<Long> arrayStringConvertList(Iterable<String> it) {
    List<Long> result = new ArrayList<Long>();
    for (String a : it) {
        result.add(Long.parseLong(a));
    }/*from   w w w  . ja  v a  2s  .c o m*/
    return result;
}

From source file:Main.java

public static boolean phoneNumberRule(String phone) {
    boolean result = false;
    long min = 13000000000L;
    long max = 18999999999L;
    long data = 0;
    try {/*from  w  w w . ja v  a2  s . c o  m*/
        data = Long.parseLong(phone);
    } catch (NumberFormatException e) {
        result = false;
        e.printStackTrace();
    }
    if (phone.length() != 11)
        result = false;
    else if (data < min || data > max)
        result = false;
    else
        result = true;
    return result;
}

From source file:Main.java

public static List<Long> stringsToLongs(List<String> list) {

    List<Long> result = new ArrayList<Long>();

    for (String str : list) {
        result.add(Long.parseLong(str));
    }//from  w  ww  . j a  va2  s  . c o m

    return result;
}

From source file:Main.java

public static long doLong(Object obj, long defValue) {
    return obj != null ? Long.parseLong(obj.toString()) : defValue;
}

From source file:Main.java

public static final long objectToLong(Object o) {
    if (o instanceof Number)
        return ((Number) o).longValue();
    try {// ww w  .j  a  v a2 s  . co  m
        if (o == null)
            return -1L;
        else
            return Long.parseLong(o.toString());
    } catch (NumberFormatException e) {
        return -1L;
    }
}

From source file:Main.java

@SuppressLint("SimpleDateFormat")
public static String getLongToDate(String time) {

    long foo = Long.parseLong(time);
    Date date = new Date(foo);
    DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
    return (formatter.format(date));
}