Java Utililty Methods Day Add

List of utility methods to do Day Add

Description

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

Method

DateaddDays(Date date, int days)
add Days
if (date == null)
    return date;
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH) + days);
return calendar.getTime();
DateaddDays(Date date, int daysOffset, boolean stripTime)
Adds specified number of days to date and, optionally strips the time component.
if (date == null) {
    return null;
Calendar calendar = Calendar.getInstance();
calendar.setLenient(false); 
calendar.setTime(date); 
if (stripTime) { 
    calendar.set(Calendar.HOUR_OF_DAY, 0);
...
DateaddDays(Date date, int daysToAdd)
add Days
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
calendar.add(Calendar.DAY_OF_MONTH, daysToAdd);
return calendar.getTime();
...
DateaddDays(Date date, int i)
add Days
Date result;
Calendar calendar = addDaysRetCalendar(date, i);
result = calendar.getTime();
return result;
DateaddDays(Date dt, int numDays)
Add a number of days to the given day.
if (dt == null)
    return null;
GregorianCalendar gc = new GregorianCalendar();
gc.setTime(dt);
gc.add(Calendar.DATE, numDays);
return gc.getTime();
DateaddDays(Date start, int days)
add Days
Calendar now = Calendar.getInstance();
now.setTime(start);
Calendar working;
working = (Calendar) now.clone();
working.add(Calendar.DAY_OF_YEAR, days);
return working.getTime();
DateaddDays(Date startDate, int numDays)
add Days
Calendar inst = GregorianCalendar.getInstance();
inst.setTime(startDate);
inst.add(Calendar.DAY_OF_YEAR, numDays);
return inst.getTime();
DateaddDays(Date when, int amount)
add Days
return add(when, Calendar.DAY_OF_YEAR, amount);
DateaddDays(final Date date, final int addDays)
Adds days to the given Date object and returns it.
final Calendar dateOnCalendar = Calendar.getInstance();
dateOnCalendar.setTime(date);
dateOnCalendar.add(Calendar.DATE, addDays);
return dateOnCalendar.getTime();
DateaddDays(final Date date, final int days)
add Days
final GregorianCalendar gc = new GregorianCalendar();
gc.setTime(date);
gc.add(Calendar.DAY_OF_MONTH, days);
return gc.getTime();