List of utility methods to do Date Between
int | betweenTwoDates(Date date1, Date date2) between Two Dates return (int) ((getMillis(date1) - getMillis(date2)) / (24 * 3600 * 1000)); |
int | daysBetween(Date d1) days Between return (int) ((cal.getTime().getTime() - d1.getTime()) / (1000 * 60 * 60 * 24)); |
long | daysBetween(Date d1, Date d2) days Between return ((d2.getTime() - d1.getTime() + (60 * 60 * 1000L)) / (60 * 60 * 1000L * 24));
|
long | daysBetween(Date date1, Date date2) days Between long diff; if (date2.after(date1)) { diff = date2.getTime() - date1.getTime(); } else { diff = date1.getTime() - date2.getTime(); return diff / (24 * 60 * 60 * 1000); |
long | DaysBetween(Date date1, Date date2) Days Between if (date2 == null) date2 = new Date(); long day = (date2.getTime() - date1.getTime()) / 86400000L; return day; |
int | daysBetween(Date smdate, Date bdate) days Between SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); smdate = sdf.parse(sdf.format(smdate)); bdate = sdf.parse(sdf.format(bdate)); Calendar cal = Calendar.getInstance(); cal.setTime(smdate); long time1 = cal.getTimeInMillis(); cal.setTime(bdate); long time2 = cal.getTimeInMillis(); ... |
int | daysBetween(Date smdate, Date bdate) days Between SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); smdate = sdf.parse(sdf.format(smdate)); bdate = sdf.parse(sdf.format(bdate)); Calendar cal = Calendar.getInstance(); cal.setTime(smdate); long time1 = cal.getTimeInMillis(); cal.setTime(bdate); long time2 = cal.getTimeInMillis(); ... |
String | daysBetween(Date smdate, Date bdate) days Between String days = ""; try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); smdate = sdf.parse(sdf.format(smdate)); bdate = sdf.parse(sdf.format(bdate)); Calendar cal = Calendar.getInstance(); cal.setTime(smdate); long time1 = cal.getTimeInMillis(); ... |
Integer | daysBetween(Date smdate, Date bdate) days Between try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); smdate = sdf.parse(sdf.format(smdate)); bdate = sdf.parse(sdf.format(bdate)); Calendar cal = Calendar.getInstance(); cal.setTime(smdate); long time1 = cal.getTimeInMillis(); cal.setTime(bdate); ... |
long | daysBetween(Date startDate, Date endDate) days Between Calendar start = Calendar.getInstance();
start.setTime(startDate);
Calendar end = Calendar.getInstance();
end.setTime(endDate);
return daysBetween(start, end);
|