List of utility methods to do Date Interval Get
int | minutesBetween(Date dt1, Date dt2) minutes Between long msDiff = millisecondsBetween(dt1, dt2); if (msDiff == 0) return 0; return (int) (msDiff / 60000); |
int | minutesBetween(Date dt1, Date dt2) minutes Between long msDiff = millisecondsBetween(dt1, dt2); if (msDiff == 0) return 0; return (int) (msDiff / 60000); |
Date | offsetMinute(Date date, int offset) offset Minute Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.MINUTE,
(calendar.get(Calendar.MINUTE) + offset));
return calendar.getTime();
|
Date | offsetSecond(Date date, int offset) offset Second Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.SECOND,
(calendar.get(Calendar.SECOND) + offset));
return calendar.getTime();
|
long | secondBetweenDate(Date date1, Date date2) second Between Date long d = date1.getTime() - date2.getTime(); return d / 1000; |
int | secondDiff(Date date1, Date date2) second Diff long diff = date1.getTime() - date2.getTime(); long day = diff / ND; long min = diff % ND % NH / NM + day * 24 * 60; return (int) min; |
int | secondDiff(String startTime, String endTime) second Diff SimpleDateFormat sd = new SimpleDateFormat(YMD_DASH_WITH_TIME); long diff = 0; long min = 0; try { diff = sd.parse(endTime).getTime() - sd.parse(startTime).getTime(); long day = diff / ND; min = diff % ND % NH / NM + day * 24 * 60; ... |
int | secondsBetween(Date dt1, Date dt2) seconds Between long msDiff = millisecondsBetween(dt1, dt2); if (msDiff == 0) { return 0; return (int) (msDiff / 1000); |
int | getDateOffset() get Date Offset int day = getDay(); int hour = getHour(); int minute = getMinute(); int offset = 0; if (day == Calendar.SATURDAY) { offset++; } else if (day == Calendar.FRIDAY && (hour > 15 || hour == 15 && minute >= 15)) { ... |
long | interval(Date date) interval return (Calendar.getInstance(TimeZone.getTimeZone("GMT+08:00")) .getTimeInMillis() - date.getTime()) / 1000; |