Java Utililty Methods Date After

List of utility methods to do Date After

Description

The list of methods to do Date After are organized into topic(s).

Method

booleanafter(Date point, Date when)
Returns true if the given from Date is after the given when Date otherwise false.
final Calendar pointCalendar = Calendar.getInstance();
pointCalendar.setTime(point);
final Calendar whenCalendar = Calendar.getInstance();
whenCalendar.setTime(when);
return pointCalendar.after(whenCalendar);
booleanafterDay(final Date date1, final Date date2)
Get date one day after specified one.
if (date1 == null)
    return false;
return getStartOfDate(date1).after(getStartOfDate(date2));
DateafterMonth(Date dateTime)
after Month
Calendar now = Calendar.getInstance();
now.setTime(dateTime);
int year = now.get(Calendar.YEAR);
int month = now.get(Calendar.MONTH) + 1;
int day = 1;
now.set(year, month, day);
return now.getTime();
DateafterOneDay(Date depdt)
after One Day
Calendar calendar = Calendar.getInstance();
calendar.setTime(depdt);
calendar.add(Calendar.DAY_OF_MONTH, 1);
return calendar.getTime();
DatedateAfter(Date date, int years, int months)
date After
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.YEAR, years);
calendar.add(Calendar.MONTH, months);
return calendar.getTime();
DatedateAfter(Date origDate, int amount, int timeUnit)
date After
Calendar calendar = Calendar.getInstance();
calendar.setTime(origDate);
calendar.add(timeUnit, amount);
return calendar.getTime();
DatedateAfterNMonths(Date dt, int n)
date After N Months
Calendar cal = Calendar.getInstance();
cal.setTime(dt);
cal.add(Calendar.MONTH, n);
return cal.getTime();
DatedaysAfter(Date dateInst, int numDays)
Method to return a Date instance which is exactly numDays days after the point in time designated by the input Date
if ((numDays <= 0) || (dateInst == null)) {
    throw new IllegalArgumentException();
final Calendar cal = new GregorianCalendar();
cal.setTime(dateInst);
cal.add(Calendar.DAY_OF_YEAR, numDays);
return cal.getTime();
DategetAfter(Date comparedDate, int cursor, String unit)
get After
Calendar calendar = Calendar.getInstance();
calendar.setTime(comparedDate);
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH);
int date = calendar.get(Calendar.DATE);
int hour = calendar.get(Calendar.HOUR_OF_DAY);
int minute = calendar.get(Calendar.MINUTE);
int second = calendar.get(Calendar.SECOND);
...
DategetAfterDay(Date date, int afterDays)
get After Day
ca.setTime(date);
ca.add(Calendar.DATE, 1);
return ca.getTime();