Java Utililty Methods Calendar Add

List of utility methods to do Calendar Add

Description

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

Method

voidaddDate(Calendar baseDate, int diffDate, TimeZone timezone)
add Date
baseDate.add(Calendar.DATE, diffDate);
DateaddDate(Date date, int calendarField, int amount)
add Date
assertDateParamsRequired(date);
Calendar c = Calendar.getInstance();
c.setTime(date);
c.add(calendarField, amount);
return c.getTime();
DateaddDate(Date date, int calendarField, int numberToAdd)
This method allows you to add to a java.util.Date returning a Date instead of void like the Calendar does
Calendar c = Calendar.getInstance();
c.setTime(date);
c.add(calendarField, numberToAdd);
return c.getTime();
CalendaraddDayOffset(final Calendar date, long offset)
add Day Offset
Calendar newDate = new GregorianCalendar();
newDate.setTimeInMillis(date.getTimeInMillis());
newDate.add(Calendar.DAY_OF_MONTH, safeLongToInt(offset));
return newDate;
voidaddDays(Calendar aTarget, int aAddDays)
add Days
aTarget.add(Calendar.DATE, aAddDays);
voidaddDays(Calendar calendar, int days)
Add the given amount of days to the given calendar.
calendar.add(Calendar.DATE, days);
CalendaraddDays(Calendar src, int days)
add Days
Calendar dest = deepCopy(src);
dest.add(Calendar.DATE, days);
return dest;
DateaddDays(final int days, final Calendar from)
Add the given number of days to the given date
return addDays(days, from.getTimeInMillis());
CalendaraddDayToCalendar(Calendar calendar, int day)
add Day To Calendar
calendar.add(Calendar.DAY_OF_MONTH, day);
return calendar;
CalendaraddLocaleToCalendar(Calendar date, String locale)
add Locale To Calendar
if (date != null) {
    if (locale != null) {
        Calendar localizedDate = Calendar.getInstance(new Locale(locale));
        localizedDate.setTime(date.getTime());
        return localizedDate;
    } else
        return date;
return null;