List of utility methods to do Date After
boolean | after(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); |
boolean | afterDay(final Date date1, final Date date2) Get date one day after specified one. if (date1 == null) return false; return getStartOfDate(date1).after(getStartOfDate(date2)); |
Date | afterMonth(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(); |
Date | afterOneDay(Date depdt) after One Day Calendar calendar = Calendar.getInstance();
calendar.setTime(depdt);
calendar.add(Calendar.DAY_OF_MONTH, 1);
return calendar.getTime();
|
Date | dateAfter(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();
|
Date | dateAfter(Date origDate, int amount, int timeUnit) date After Calendar calendar = Calendar.getInstance();
calendar.setTime(origDate);
calendar.add(timeUnit, amount);
return calendar.getTime();
|
Date | dateAfterNMonths(Date dt, int n) date After N Months Calendar cal = Calendar.getInstance();
cal.setTime(dt);
cal.add(Calendar.MONTH, n);
return cal.getTime();
|
Date | daysAfter(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(); |
Date | getAfter(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); ... |
Date | getAfterDay(Date date, int afterDays) get After Day ca.setTime(date);
ca.add(Calendar.DATE, 1);
return ca.getTime();
|