List of utility methods to do Day Between
int | getDiffBetweenQuarter(Date latestDate, Date current) get Diff Between Quarter Calendar calCurrent = Calendar.getInstance(); calCurrent.setTime(current); Calendar calLatest = Calendar.getInstance(); calLatest.setTime(latestDate); int latestQuarterNum = getQuarterNum(latestDate); int currentQuarterNum = getQuarterNum(current); if (calCurrent.get(Calendar.YEAR) - calLatest.get(Calendar.YEAR) > 0) { int diff = calCurrent.get(Calendar.YEAR) - calLatest.get(Calendar.YEAR); ... |
int | getDiffDays(Date date1, Date date2) get Diff Days Calendar c = Calendar.getInstance(); c.setTime(date1); long time1 = c.getTimeInMillis(); c.setTime(date2); long time2 = c.getTimeInMillis(); long between_days = (time2 - time1) / MILLIS_ONE_DATE; return Integer.parseInt(String.valueOf(between_days)); |
int | getDiffDays(String startDate, String endDate) get Diff Days long diff = 0; SimpleDateFormat ft = null; if (startDate.indexOf("/") > 0 && endDate.indexOf("/") > 0) { ft = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); if (startDate.indexOf("-") > 0 && endDate.indexOf("-") > 0) { ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { Date sDate = ft.parse(startDate + " 00:00:00"); Date eDate = ft.parse(endDate + " 00:00:00"); diff = eDate.getTime() - sDate.getTime(); diff = diff / 86400000; } catch (ParseException e) { e.printStackTrace(); return (int) diff; |
long | getDifferDays(Date d1, Date d2) get Differ Days DateFormat df1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); long diff = d1.getTime() - d2.getTime(); long days = diff / (1000 * 60 * 60 * 24); return days; |
long | getDifferDays(String date1, String date2) get Differ Days Date tempDate1 = str2date(date1); Date tempDate2 = str2date(date2); long differDays = 0; differDays = tempDate2.getTime() - tempDate1.getTime(); long todaySeconds = 1000 * 24 * 60 * 60; return differDays / todaySeconds + 1; |
String | getDifference(Date d1, Date d2) Get date difference => d1 - d2. Calendar calendar = new GregorianCalendar(); calendar.setTime(d2); int year2 = calendar.get(Calendar.YEAR); int day2 = calendar.get(Calendar.DAY_OF_YEAR); int hour2 = calendar.get(Calendar.HOUR_OF_DAY); int min2 = calendar.get(Calendar.MINUTE); calendar.setTime(d1); int year1 = calendar.get(Calendar.YEAR); ... |
int | getDifferenceInDays(final Date startDate, final Date endDate) Determines the difference in days of two dates final GregorianCalendar c = gregorianCalendarThreadLocal.get(); c.setTime(trimDate(startDate)); final long startMilli = c.getTimeInMillis() + c.getTimeZone().getOffset(c.getTimeInMillis()); c.setTime(trimDate(endDate)); final long endMilli = c.getTimeInMillis() + c.getTimeZone().getOffset(c.getTimeInMillis()); return (int) ((endMilli - startMilli) / MILLISECONDS_PER_DAY); |
int | getDifferenceOfDays(String dateFromStr, String dateToStr, String dateFormat) get Difference Of Days java.util.Date dateFrom = parseDate(dateFromStr, dateFormat);
java.util.Date dateTo = parseDate(dateToStr, dateFormat);
return getDifferenceOfDays(dateFrom, dateTo);
|
int | getDifferencesBetweenIndicateDays(final Date minorDate, final Date majorDate) Calculate diff in days between dates. int numDiff = 0; if (majorDate.after(minorDate)) { final Calendar calendarMinor = new GregorianCalendar(); calendarMinor.setTime(minorDate); final int dayYearMinor = calendarMinor.get(Calendar.DAY_OF_YEAR); final int yearMinor = calendarMinor.get(Calendar.YEAR); final Calendar calendarMajor = new GregorianCalendar(); calendarMajor.setTime(majorDate); ... |
long | getDiffMilliSeconds(Date form, Date to) get Diff Milli Seconds Calendar cal1 = new GregorianCalendar(); cal1.setTime(form); Calendar cal2 = new GregorianCalendar(); cal2.setTime(to); return (cal1.getTimeInMillis() - cal2.getTimeInMillis()); |