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

StringgetFormattedTimestamp(@Nonnull Date date)
get Formatted Timestamp
synchronized (FORMAT_TIMESTAMP) {
    return FORMAT_TIMESTAMP.format(date);
StringgetFormattedTimestamp(File file)
get Formatted Timestamp
return file != null && file.exists() ? getLocaleFormattedDateTime(file.lastModified()) : null;
StringgetFormattedTimeStamp(long timestamp, String formatString)
get Formatted Time Stamp
Date date = new Date(timestamp);
DateFormat formatter = new SimpleDateFormat(formatString, Locale.US);
return (formatter.format(date));
DateFormatgetFullTimestampFormatter(Locale locale)
get Full Timestamp Formatter
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, locale);
String localeString = locale.toString();
if (localeString.equals("zh_SG")) {
    return new SimpleDateFormat("dd/MM/yyyy a hh:mm");
} else if (localeString.equals("ko")) {
    return changeDateFormatPattern(dateFormat, "y+\\. *M+\\. *d+", "yyyy-MM-dd");
return changeDateFormatPattern(dateFormat, "y+", "yyyy");
...
StringgetTimestamp(boolean useTwentyFourFormat)
Generates message timestamp.
return "<small>" + getCurrentHour(useTwentyFourFormat) + ":" + getCurrentMinutes() + "</small> ";
StringgetTimeStamp(String format)
Gets a timestamp using the given format.
Date date = new Date();
SimpleDateFormat sdf;
try {
    sdf = new SimpleDateFormat(format);
} catch (NullPointerException | IllegalArgumentException e) {
    sdf = new SimpleDateFormat(TIMESTAMP_FORMAT);
return sdf.format(date);
...
StringgetTimestamp(String format)
Get timestamp.
return _datetime(format);
SimpleDateFormatgetTimestampFormat()
get Timestamp Format
ThreadLocal<SimpleDateFormat> tl = timestampFormatPool.get(timestampPattern);
if (null == tl) {
    synchronized (timestampFormatLock) {
        tl = timestampFormatPool.get(timestampPattern);
        if (null == tl) {
            tl = new ThreadLocal<SimpleDateFormat>() {
                @Override
                protected synchronized SimpleDateFormat initialValue() {
...
StringgetTimeStampFormat(Date date)
get Time Stamp Format
return mDateFormat.format(date) + " " + mElapsedTimeFormat.format(date);
StringgetTimeStampFormat(Date date)
get Time Stamp Format
if (date == null)
    return null;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd-HH.mm.ss.SSSSSS");
return simpleDateFormat.format(date);