List of utility methods to do Date Difference
int | diffDay(Date date1, Date date2) diff Day Calendar aCalendar = Calendar.getInstance(); aCalendar.setTime(date1); int day1 = aCalendar.get(Calendar.DAY_OF_YEAR); Calendar bCalendar = Calendar.getInstance(); bCalendar.setTime(date2); int day2 = bCalendar.get(Calendar.DAY_OF_YEAR); return day2 - day1; |
long | diffDay(Date start, Date end) diff Day return offset(start, end, Calendar.DAY_OF_YEAR);
|
int | diffDay(Date startDate, Date endDate) Returns the number of days difference between two dates DUPLICATE METHOD? if (startDate == null || endDate == null) { return 0; return (int) ((endDate.getTime() - startDate.getTime()) / (1000 * 60 * 60 * 24)); |
int | differDays(Date src, Date target) differ Days Calendar cal = getDateCalendar(src); Calendar cal2 = getDateCalendar(target); return new Long((cal2.getTimeInMillis() - cal.getTimeInMillis()) / (1000 * 60 * 60 * 24)).intValue(); |
long | difference(Date date1, Date date2) difference Calendar cal1 = Calendar.getInstance(); cal1.setTime(date1); Calendar cal2 = Calendar.getInstance(); cal2.setTime(date2); if (cal2.after(cal1)) { return cal2.getTimeInMillis() - cal1.getTimeInMillis(); return cal1.getTimeInMillis() - cal2.getTimeInMillis(); ... |
int | differenceDay(Date toDate, Date fromDate) difference Day Calendar to = Calendar.getInstance(); to.setTime(toDate); Calendar from = Calendar.getInstance(); from.setTime(fromDate); long day = (to.getTimeInMillis() - from.getTimeInMillis()) / 1000 / 60 / 60 / 24; return (int) day; |
double | DifferenceInMilliseconds(Date date1, Date date2) Difference In Milliseconds return GetTimeInMilliseconds(date1) - GetTimeInMilliseconds(date2);
|
int | differenceInMonths(Date beginningDate, Date endingDate) calculate difference in months between the arguments. if (beginningDate == null || endingDate == null) { return 0; Calendar cal1 = new GregorianCalendar(); cal1.setTime(beginningDate); Calendar cal2 = new GregorianCalendar(); cal2.setTime(endingDate); return differenceInMonths(cal1, cal2); ... |
double | DifferenceInSeconds(Date date1, Date date2) Finds the difference in seconds between two dates. return DifferenceInMilliseconds(date1, date2) / 1000.0;
|
int | differenceMonth(Date date1, Date date2) difference Month Calendar cal1 = Calendar.getInstance(timeZone); cal1.setTime(date1); cal1.set(Calendar.DATE, 1); Calendar cal2 = Calendar.getInstance(timeZone); cal2.setTime(date2); cal2.set(Calendar.DATE, 1); int count = 0; if (cal1.before(cal2)) { ... |