List of utility methods to do Hour Add
Date | addHH(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(); |
Date | addHour(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();
|
Date | addHour(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(); ... |
Calendar | addHour(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; |
Date | addHours(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(); |
long | addHours(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();
|