List of utility methods to do Day Between
int | differentDaysByMillisecond(Date date1, Date date2) different Days By Millisecond int days = (int) ((date2.getTime() - date1.getTime()) / (1000 * 3600 * 24)); return days; |
Long | diffInDays(Date date1, Date date2) diff In Days try { SimpleDateFormat sdf = new SimpleDateFormat(DATEFORMAT); String lastUpdateInUTCString = sdf.format(date1); String nowInUTCString = sdf.format(date2); Date lastUpdateInUTC; lastUpdateInUTC = stringDateToDate(lastUpdateInUTCString); Date nowInUTC = stringDateToDate(nowInUTCString); long nowInUTCMilis = nowInUTC.getTime(); ... |
Integer | getBeteenDays(String begin, String end, String format) get Beteen Days SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); Calendar cal = Calendar.getInstance(); cal.setTime(sdf.parse(begin)); long time1 = cal.getTimeInMillis(); cal.setTime(sdf.parse(end)); long time2 = cal.getTimeInMillis(); long between_days = (time2 - time1) / (1000 * 3600 * 24); return Integer.parseInt(String.valueOf(between_days)) + 1; ... |
int | getBetweenDays(long longValue1, long longValue2) get Between Days long betweenDays = ((longValue1 - longValue2) / 1000) / (60 * 60 * 24); return Math.abs((int) betweenDays); |
List | getBetweenDays(String start, String end) get Between Days List<String> list = new ArrayList<String>(); try { Calendar c1 = Calendar.getInstance(); Calendar c2 = Calendar.getInstance(); Date d1 = DATE_FORMAT.parse(start); Date d2 = DATE_FORMAT.parse(end); c1.setTime(d1); c2.setTime(d2); ... |
List | getBetweenTwoDayCalender(String startDay, String endDay) get Between Two Day Calender List<String> list = new ArrayList<String>(); if (startDay == null || startDay.equals("")) { return null; if (endDay == null || endDay.equals("")) { return null; SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd"); ... |
Date | getDateDiff(Date date, int day) get Date Diff cal.setTime(date); cal.add(Calendar.DAY_OF_MONTH, day); Date tmpdate = new Date(cal.getTime().getTime()); return tmpdate; |
long | getDateDiff(final Date startDate, final Date endDate) get Date Diff if (startDate != null && endDate != null) { final Calendar startCalendar = Calendar.getInstance(); startCalendar.setTime(startDate); final long startDateMiliSeconds = startCalendar.getTimeInMillis(); final Calendar endCalendar = Calendar.getInstance(); endCalendar.setTime(endDate); final long endDateMiliSeconds = endCalendar.getTimeInMillis(); final long result = (endDateMiliSeconds - startDateMiliSeconds) / 1000; ... |
int | getDateDifference(Date date1, Date date2) Returns number of days between date1 and date2, such that date1 + days = date2 int oneDay = 1000 * 60 * 60 * 24; Calendar cal1 = getCalendarDate(date1); Calendar cal2 = getCalendarDate(date2); return (int) ((cal1.getTimeInMillis() - cal2.getTimeInMillis()) / oneDay); |
Integer | getDateDifferenceinDays(Date date1, Date date2) get Date Differencein Days if (date1 == null || date2 == null) return null; long diff = 0L; diff = Math.abs(date1.getTime() - date2.getTime()); long oneDayseconds = getSecondsForDay(); Integer result = (int) (diff / oneDayseconds); return result; |