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 getStringDate(long l) {
    Date date = new Date(Long.parseLong((new StringBuilder()).append(l).append("000").toString()));
    return (new SimpleDateFormat("dd MMM yyyy", Locale.ENGLISH)).format(date);
}

From source file:Main.java

public static long parseLong(String v) {

    if (v == null || v.equals(""))
        return 0L;

    return Long.parseLong(v);

}

From source file:Main.java

public static long tryParseLong(String text, long def) {
    long ret = 0;
    try {//from   ww w.  j a  va2 s.  c  o  m
        ret = Long.parseLong(text);
    } catch (Exception e) {
        ret = def;
    }

    return ret;
}

From source file:Main.java

public static String timeStamp2String(String timestampString, String formats) {
    Long timestamp = Long.parseLong(timestampString) * 1000;
    String date = new SimpleDateFormat(formats).format(new Date(timestamp));
    return date;/*from   w  w w .  ja  v  a 2 s. com*/
}

From source file:Main.java

public static long parseJsonDate(String jsonDate) {
    String[] result = jsonDate.split("[(]");
    String[] resultTwo = result[1].split("[+]");
    return Long.parseLong(resultTwo[0]);
}

From source file:Main.java

public static String getDate(String date_long) {
    Long time_millisecond = Long.parseLong(date_long);
    Date date = new Date(time_millisecond);
    SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM", Locale.ENGLISH);
    return dateFormat.format(date);
}

From source file:Main.java

public static String getTime(String date_long) {
    Long time_millisecond = Long.parseLong(date_long);
    Date date = new Date(time_millisecond);
    SimpleDateFormat dateFormat = new SimpleDateFormat("h:mm a", Locale.ENGLISH);
    return dateFormat.format(date);
}

From source file:Main.java

public static Number string2number(final String iText) {
    if (iText.indexOf('.') > -1)
        return Double.parseDouble(iText);
    else//from w w  w  .j ava 2 s.  com
        return Long.parseLong(iText);
}

From source file:Main.java

public static Date toDate(String s) {
    if (s == null) {
        return null;
    }//from ww w .  j  a  va2s. c o  m
    try {
        return new Date(Long.parseLong(s));
    } catch (NumberFormatException e) {
        return null;
    }
}

From source file:Main.java

public static String timeStampToTimeString(String timeStamp, SimpleDateFormat format) {
    Date date = new Date(Long.parseLong(timeStamp));
    return format.format(date);
}