List of utility methods to do Date Add
Date | add(Date date, int calendarField, int amount) Used internally to add/subtract amount to specific calendar field. if (StringUtils.isNull(date)) { throw new NullPointerException("date cannot be null"); Calendar c = Calendar.getInstance(); c.setTime(date); c.add(calendarField, amount); return c.getTime(); |
Timestamp | add(Date date, int calendarField, int amount) add if (date == null) { throw new IllegalArgumentException("The date must not be null"); Calendar c = Calendar.getInstance(); c.setTime(date); c.add(calendarField, amount); return new Timestamp(c.getTimeInMillis()); |
Date | add(Date date, int calendarField, int amount) Adds to a date returning a new object. if (date == null) { throw new IllegalArgumentException("The date must not be null"); Calendar c = Calendar.getInstance(); c.setTime(date); c.add(calendarField, amount); return c.getTime(); |
Date | addDay(Date date, int days) add Day Calendar c = getCalendar(date); if (c == null) return null; c.add(Calendar.DAY_OF_MONTH, days); return c.getTime(); |
Timestamp | addDays(Date date, int amount) add Days return add(date, Calendar.DAY_OF_MONTH, amount);
|
Date | addDays(Date date, int amount) Adds a number of days to a date returning a new object. return add(date, Calendar.DAY_OF_MONTH, amount);
|
Date | addDaysToDate(Date date, int daysToBeAdded) Add / Subtract given no of days to Date . if (StringUtils.isNull(date)) { throw new NullPointerException("date cannot be null"); return add(date, Calendar.DATE, daysToBeAdded); |
Timestamp | addHours(Date date, int amount) add Hours return add(date, Calendar.HOUR_OF_DAY, amount);
|
Date | addHours(Date date, int amount) Adds a number of hours to a date returning a new object. return add(date, Calendar.HOUR_OF_DAY, amount);
|
Date | addHoursToDate(Date date, int hoursToBeAdded) Add / Subtract given no of hours to Date . if (StringUtils.isNull(date)) { throw new NullPointerException("date cannot be null"); return add(date, Calendar.HOUR, hoursToBeAdded); |