Java Utililty Methods Hour Add

List of utility methods to do Hour Add

Description

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

Method

DateaddHH(Date date, int i)
add HH
if (date == null)
    return null;
Calendar c = new GregorianCalendar();
c.setTime(date);
c.add(Calendar.HOUR, i);
return c.getTime();
DateaddHour(Date baseDate, int hour, TimeZone timezone)
add Hour
Calendar cal = Calendar.getInstance();
cal.setTimeZone(timezone);
cal.setTime(baseDate);
cal.add(Calendar.HOUR_OF_DAY, hour);
return cal.getTime();
DateaddHour(Date date, boolean up)
add Hour
Calendar cal = Calendar.getInstance();
cal.setTime(date);
if (up) {
    cal.add(Calendar.HOUR_OF_DAY, 1);
} else {
    cal.add(Calendar.HOUR_OF_DAY, -1);
return cal.getTime();
...
CalendaraddHour(java.util.Date d, int h)
add Hour
if (d == null)
    return null;
Calendar cal = Calendar.getInstance();
cal.setTime(d);
cal.add(Calendar.HOUR, h);
return cal;
DateaddHours(Date date, int hours)
Adds the number of hours to the specified java.util.Date Date object.
Calendar temp = new GregorianCalendar();
temp.setTime(date);
temp.set(Calendar.HOUR_OF_DAY, hours);
return temp.getTime();
longaddHours(long date, int hours)
Adds the specified amount of hours to a date
Calendar calendar = Calendar.getInstance(UTC);
calendar.setTimeInMillis(date);
calendar.add(Calendar.HOUR, hours);
return calendar.getTimeInMillis();