Java Utililty Methods Long Number to Date

List of utility methods to do Long Number to Date

Description

The list of methods to do Long Number to Date are organized into topic(s).

Method

StringformatDateTimeStamp(final long timeInMillis, final String dateFormatString)
Formats a date into a given timestamp format.
String tmpString = "";
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(timeInMillis);
java.util.Date date = cal.getTime();
SimpleDateFormat format = new SimpleDateFormat(dateFormatString);
tmpString = format.format(date);
return tmpString;
StringformateDate(Long date, String format)
formate Date
if (date == null) {
    return "";
SimpleDateFormat dateFormat = new SimpleDateFormat(format);
return dateFormat.format(new Date(date));
StringformatEpoch(long date)
format Epoch
final String parsedDate = rubyDateFormat.format(parseEpoch(date));
assert (parsedDate != null);
return parsedDate;
StringformatHttpDate(long d)
format Http Date
GregorianCalendar gc = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
gc.setTimeInMillis(d);
return getSDF().format(gc.getTime());
StringformatHTTPDate(long pTime)
Formats the time to a HTTP date, using the RFC 1123 format, as described in RFC 2616 (HTTP/1.1), sec.
return formatHTTPDate(new Date(pTime));
StringformatHttpDate(long time)
format Http Date
synchronized (HTTP_DATE_FORMAT) {
    return HTTP_DATE_FORMAT.format(new Date(time * 1000));
StringgetDatebyLong(long dt)
get Dateby Long
Date date = new Date(dt);
return formatDate(date, "yyyy-MM-dd");
StringgetDateByLongTime(long time)
get Date By Long Time
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
Date dt = new Date(time);
String timeStr = sdf.format(dt);
return timeStr;
StringgetDateByMis(long m)
get Date By Mis
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
long now = System.currentTimeMillis();
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(now + m);
return formatter.format(calendar.getTime());
StringgetDateByMisSecond(long misSecond)
get Date By Mis Second
if (misSecond < 0) {
    throw new IllegalArgumentException("The misSecond must not be negative");
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(misSecond);
java.util.Date date = cal.getTime();
return getStrDate(date);