List of utility methods to do Date Interval Get
int | getInterval(String beginMonth, String endMonth) get Interval int intBeginYear = Integer.parseInt(beginMonth.substring(0, 4)); int intBeginMonth = Integer.parseInt(beginMonth .substring(beginMonth.indexOf("-") + 1)); int intEndYear = Integer.parseInt(endMonth.substring(0, 4)); int intEndMonth = Integer.parseInt(endMonth.substring(endMonth .indexOf("-") + 1)); return ((intEndYear - intBeginYear) * 12) + (intEndMonth - intBeginMonth) + 1; ... |
double | getIntervalDays(Date minDate, Date maxDate) get Interval Days double days = 0; if (minDate == null || maxDate == null) { return days; try { days = getIntervalHours(minDate, maxDate) / 24; } catch (Exception e) { e.printStackTrace(); ... |
long | getIntervalDays(String sd, String ed) get Interval Days return ((java.sql.Date.valueOf(ed)).getTime() - (java.sql.Date
.valueOf(sd)).getTime()) / (3600 * 24 * 1000);
|
double | getIntervalHours(Date minDate, Date maxDate) get Interval Hours double days = 0.0; if (minDate == null || maxDate == null) { return days; try { days = getIntervalMinutes(minDate, maxDate) / 60; } catch (Exception e) { e.printStackTrace(); ... |
double | getIntervalMinutes(Date minDate, Date maxDate) get Interval Minutes double days = 0.0; if (minDate == null || maxDate == null) { return days; try { long interval = maxDate.getTime() - minDate.getTime(); days = Double.valueOf(interval) / 1000 / 60; } catch (Exception e) { ... |
int | getIntervalYears(Date date1, Date date2) get Interval Years Calendar firstCal = Calendar.getInstance(); Calendar secondCal = Calendar.getInstance(); firstCal.setTime(date1); secondCal.setTime(date2); int year = firstCal.get(Calendar.YEAR) - secondCal.get(Calendar.YEAR); int month = firstCal.get(Calendar.MONTH) - secondCal.get(Calendar.MONTH); ... |
long | hoursBetweenDate(Date date1, Date date2) hours Between Date long d = date1.getTime() - date2.getTime(); return d / 3600000; |
long | millisecondsBetween(Date dt1, Date dt2) milliseconds Between if (dt1 == null || dt2 == null) return 0; return Math.abs(dt1.getTime() - dt2.getTime()); |
long | millisecondsBetween(Date dt1, Date dt2) milliseconds Between if (dt1 == null || dt2 == null) return 0; return Math.abs(dt1.getTime() - dt2.getTime()); |
long | minuteBetweenDate(Date date1, Date date2) minute Between Date long d = date1.getTime() - date2.getTime(); return d / 60000; |