Java Utililty Methods Timestamp Format

List of utility methods to do Timestamp Format

Description

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

Method

StringfriendlyTimestamp(Date date)
friendly Timestamp
return format(date, friendlyTimestampFormat());
SimpleDateFormatfriendlyTimestampFormat()
friendly Timestamp Format
return new SimpleDateFormat(formatFriendlyTimestamp);
java.text.SimpleDateFormatfriendlyTimestampFormat()
friendly Timestamp Format
return new java.text.SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
CalendargetCalendar(String timeStamp, final String dateFormat)
Gets the calendar.
DateTime dt = new DateTime(DateTimeZone.UTC);
Calendar calendar = dt.toCalendar(Locale.ENGLISH);
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FMT_FULL, Locale.ENGLISH);
Date date = sdf.parse(timeStamp);
calendar.setTime(date);
return calendar;
longgetEpochTime(String dateTimeStamp, SimpleDateFormat dateFormat)
get Epoch Time
return getEpochTime(dateTimeStamp, false, dateFormat, 0);
SimpleDateFormatgetFormatForTimestamp(final Calendar now, final Calendar timestamp)
get Format For Timestamp
if (now.get(Calendar.YEAR) != timestamp.get(Calendar.YEAR)) {
    return new SimpleDateFormat("yyyy-MM-dd\nHH:mm");
if (now.get(Calendar.DAY_OF_YEAR) != timestamp.get(Calendar.DAY_OF_YEAR)) {
    return new SimpleDateFormat("MM-yy\nHH:mm");
return new SimpleDateFormat("HH:mm");
DategetFormattedDate(String timestamp)
get Formatted Date
return getDateFormat().parse(timestamp);
StringgetFormattedDateFromTimestamp(long timestamp)
get Formatted Date From Timestamp
mCalendar.setTimeInMillis(timestamp);
return mDateFormatDump.format(mCalendar.getTime());
StringgetFormattedTime(long timestamp, String format)
get Formatted Time
if (format == null) {
    format = TIMESTAMP_FORMAT;
SimpleDateFormat dateformat = new SimpleDateFormat(format);
return dateformat.format(new Date(timestamp));
StringgetFormattedTimestamp()
Gets a properly formatted timestamp.
return new SimpleDateFormat(DATEFORMAT_PATTERN, Locale.US).format(new Date());