Notice ".add" method.
public static Date getNextHour(Date date)
{
Calendar cal = new GregorianCalendar();
cal.setTime(date);
cal.add(Calendar.HOUR, 1);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
Date time = cal.getTime();
return time;
}
No comments:
Post a Comment