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

Calendaradd(Calendar calendar, int calendarField, int amount)
add
Calendar c = Calendar.getInstance();
c.setTime(calendar.getTime());
c.add(calendarField, amount);
return c;
Dateadd(Date _date, int _calendarField, int _amount)
add
if (_date == null) {
    return _date;
Calendar c = Calendar.getInstance();
c.setTime(_date);
c.add(_calendarField, _amount);
return c.getTime();
Dateadd(Date date, int calendarField, int amount)
add
if (date == null) {
    throw new IllegalArgumentException("The date must not be null");
} else {
    Calendar c = Calendar.getInstance();
    c.setTime(date);
    c.add(calendarField, amount);
    return c.getTime();
Dateadd(Date inputDate, int interval, int calendarUnit)
Add Interval to Date
Calendar cal = Calendar.getInstance();
cal.setTime(formateDateWithoutTime(inputDate));
cal.add(calendarUnit, interval);
return cal.getTime();
Dateadd(final Date date, final int calendarField, final int amount)
Adds to a date returning a new object.
if (date == null) {
    throw new IllegalArgumentException("The date must not be null");
final Calendar c = Calendar.getInstance();
c.setTime(date);
c.add(calendarField, amount);
return c.getTime();
Calendaradd2Calendar(Calendar cal, int years, int months, int days, int hours, int minutes, int seconds, int millis)
Adds the specified values to the values to the specified Calendar instance and returns the result.
if (years != 0)
    cal.add(Calendar.YEAR, years);
if (months != 0)
    cal.add(Calendar.MONTH, months);
if (days != 0)
    cal.add(Calendar.DAY_OF_MONTH, days);
if (hours != 0)
    cal.add(Calendar.HOUR_OF_DAY, hours);
...
voidaddCalendarDate(Calendar cal, int date)
add Calendar Date
cal.add(Calendar.DATE, date);
longaddCalendarMonthsToUnixtime(long time, int interval)
Add the specified amount of months to the given time.
The day of month will stay the same.
Calendar c = Calendar.getInstance();
c.setTimeInMillis(time);
c.add(Calendar.MONTH, interval);
return c.getTimeInMillis();
voidaddCalendarQuarterOfYear(Calendar cal, int quartersOfYear)
add Calendar Quarter Of Year
addCalendarMonth(cal, quartersOfYear * 3);
CalendaraddDate(Calendar baseDate, int addDate)
add Date
return add(baseDate, 0, 0, addDate, 0, 0, 0, 0);