Java Utililty Methods Hour Format

List of utility methods to do Hour Format

Description

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

Method

StringformatHTTPDate(Date pTime)
Formats the time to a HTTP date, using the RFC 1123 format, as described in RFC 2616 (HTTP/1.1), sec.
synchronized (HTTP_RFC1123_FORMAT) {
    return HTTP_RFC1123_FORMAT.format(pTime);
StringformatInfo(String info)
format Info
return getCurDateTime() + " : " + info + "\n";
StringformatInternal(final Date date)
Formats a date to use for internal purposes (logging, toString)
final String formatedDate = (date == null) ? "N/A"
        : new SimpleDateFormat(DEFAULT_DATE_TIME_FORMAT).format(date);
return formatedDate;
StringformatInterval(long intervalMsec)
Formats the specified time interval as an interval string with format: "d days hh:mm:ss.SSS"
long rem = intervalMsec;
long days = rem / 86400000;
rem -= days * 86400000;
long hours = rem / 3600000;
rem = -hours * 3600000;
long min = rem / 60000;
rem -= min * 60000;
long sec = rem / 1000;
...
StringformatLastModified(long lastModifiedTime)
format Last Modified
return dateFormat.format(new Date(lastModifiedTime));
StringformatMessage(String message)
format Message
return _DateFormatter.format(new Date()) + " IBController: " + message;
StringformatMM(Date date)
yyyy-MM-dd HH:mm
return YYYY_MM_DD_HH_MM_FORMAT.get().format(date);
StringformatNanosTimeUSEastern(long nanos)
format Nanos Time US Eastern
long millis = nanos / 1000000;
Formatter nanosFormat = new Formatter();
nanosFormat.format("%06d", nanos - millis * 1000000);
Date d = new Date(millis);
synchronized (US_EASTERN_FORMAT_MILLIS) {
    return US_EASTERN_FORMAT_MILLIS.format(d) + nanosFormat.toString();
DateformatNewDate(String format)
format New Date
SimpleDateFormat sdf = new SimpleDateFormat(format);
try {
    return sdf.parse(dateToString(new Date(), format));
} catch (ParseException e) {
    e.printStackTrace();
    return null;
StringformatOffset(int offset)
format Offset
int offsetHours = offset / 3600000;
int offsetMinutes = (offset / 60000) % 60;
return (HH.format(offsetHours) + MM.format(offsetMinutes));