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

StringformatHoraFormatadaHHMMSSStr(Date hora)
format Hora Formatada HHMMSS Str
SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss");
return format.format(hora);
StringformatHour(final Date date)
format Hour
return format0.format(date);
StringformatHours(Locale locale, double totalhours)
Formats the hours display for the given locale.
String result = HOURS_FORMAT.format(totalhours);
return result;
StringformatHours(long millis)
format Hours
long hours = millis / (3600 * 1000);
long leftover = millis - hours * (3600 * 1000);
long minutes = leftover / (60 * 1000);
leftover -= minutes * (60 * 1000);
long seconds = leftover / 1000;
if (hours > 0) {
    return "" + hours + ":" + timePartFormat.format(minutes) + ":" + timePartFormat.format(seconds);
if (minutes > 0) {
    return minutes + ":" + timePartFormat.format(seconds);
if (seconds == 0) {
    return "less than 1 second";
if (seconds == 1) {
    return "1 second";
return "" + seconds + " seconds";
StringformatHourTimeHToString(Date srcDate)
format Hour Time H To String
SimpleDateFormat sdf = new SimpleDateFormat("HHmm", Locale.CHINA);
return sdf.format(srcDate);
StringformatHttpDate(Date d)
format Http Date
GregorianCalendar gc = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
gc.setTime(d);
return getSDF().format(gc.getTime());
StringformatHttpDate(Date date)

Format a Date according to the HTTP/1.1 RFC.

if (date == null)
    return null;
SimpleDateFormat formatter = new SimpleDateFormat(FORMAT_822, LOCALE);
formatter.setTimeZone(TIMEZONE);
return formatter.format(date);
StringformatHttpDate(Date date)
format Http Date
return createDateFormat(DATE_FORMAT_RFC1123).format(date);
StringformatHttpDate(Date date)
Formats given Date as RFC1123 date.
return httpDateFormat.format(date);
StringformatHTTPDate(Date date)
Formats a date and time in HTTP protocol format.
return httpDateFormatter.format(date);