Java Utililty Methods Long Number to Timestamp

List of utility methods to do Long Number to Timestamp

Description

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

Method

longaddSecondsToTimeStamp(Long timestamp, int seconds)
add Seconds To Time Stamp
Date date = otpDateFormatter.parse(otpDateFormatter.format(timestamp));
calendar.setTime(date);
calendar.add(Calendar.SECOND, seconds);
long time = calendar.getTimeInMillis();
if (time < timestamp) {
    calendar.add(Calendar.DAY_OF_YEAR, 1);
return calendar.getTimeInMillis();
...
StringgetCompactStringTimestamp(long timestamp)
get Compact String Timestamp
SimpleDateFormat sdf = new SimpleDateFormat("MMddHHmmss");
Date tsDate = new Date(timestamp);
return sdf.format(tsDate);
StringgetIndex(String index, long timestamp)
get Index
return index + "-" + indexFormat.format(new Date(timestamp));
StringlongToDate(long timestamp)
long To Date
SimpleDateFormat sfd = new SimpleDateFormat("yyyy-MM-dd");
Date date1 = new Date(timestamp);
return sfd.format(date1);
StringlongToDateTime(long timestamp)
Return formatted Date String: yyyy.MM.dd HH:mm:ss Based on Unix's time() input in seconds
Date date = new Date(timestamp * 1000);
DateFormat formatter = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
return formatter.format(date);
StringlongToDateTime(long timestamp)
long To Date Time
Date date = new Date(timestamp * 1000);
DateFormat formatter = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
return formatter.format(date);
StringprettyPrintDate(long timestamp)
pretty Print Date
return sdf.format(new Date(timestamp));
StringprintTimestamp(Long c)
print Timestamp
if (c == null) {
    return null;
return s_dateFormat.format(c);
LongreverseTimestampToNormalTime(long timestamp)
reverse Timestamp To Normal Time
Long convert = MAX_TIME - timestamp;
try {
    return new SimpleDateFormat(DATE_FORMAT).parse(Long.toString(convert)).getTime();
} catch (ParseException e) {
    throw new RuntimeException(e);
Stringtimestamp(long time)
Supply timestamp to prefix informational messages.
return new SimpleDateFormat("HH:mm:ss").format(new Date(time)) + " ";