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

StringformatDate(long time)
format Date
Date date = new Date(time);
return getDateFormat().format(date);
StringformatDate(long time, String format)
Formats a Java timestamp (millis since epoch) using the current locale's timezone.
return formatDate(new Date(time), format, localZone);
StringformatDate(long time_millis)
Takes a date in milliseconds and returns the date, formatted like:
yy-mm-dd hh:mm:ss
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date(time_millis);
return format.format(date);
StringformatDate(long timeStamp)
format Date
DateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd kk:mm:ss");
Date date = new Date(timeStamp);
return dateFormat.format(date);
StringformatDate(long timestamp, String format)
format Date
if (format == null || "".equals(format)) {
    format = "yyyy-MM-dd HH:mm:ss";
SimpleDateFormat sdf = new SimpleDateFormat(format);
return sdf.format(new Date(timestamp));
StringformatDate(String format, long timestamp)
format Date
Date date = timestampToDate(timestamp);
SimpleDateFormat f = new SimpleDateFormat(format);
return f.format(date);
StringformatDate2DateStr(long date)
Format the given date time to "yyyy-MM-dd" format string.
SimpleDateFormat s = getDateFormat(DATE_FORMAT);
return s.format(new Date(date));
StringformatDate2DateStr(long date)
Format the given date time to "yyyy-MM-dd" format string.
SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd");
return s.format(new Date(date));
StringformatDateForLog(long dateTs)
format Date For Log
return formatDate(dateTs, LOG_TS_FORMAT);
StringformatDateHeader(final long date)
format Date Header
Calendar cal = Calendar.getInstance();
cal.setTime(new Date(date));
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
return new SimpleDateFormat(DATE_HEADER_FMT).format(cal.getTime()) + GMT_SUFFIX;