List of utility methods to do Calendar Compare
int | compare(Calendar c1, Calendar c2, int what) compare int number = 0; switch (what) { case Calendar.YEAR: number = c1.get(Calendar.YEAR) - c2.get(Calendar.YEAR); break; case Calendar.MONTH: int years = compare(c1, c2, Calendar.YEAR); number = 12 * years ... |
int | compareCurrentDate(String currentDate) compare Current Date DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); Date objDate = df.parse(currentDate); return compareDate(objDate, nowAsDate(), Calendar.DATE); |
boolean | isAfterRollingTime(Calendar date) Check if current time is after 19h30 Calendar today = getCalendar(); today.setTime(date.getTime()); Calendar endRollingTime = getCalendar(today.get(Calendar.YEAR), today.get(Calendar.MONTH), today.get(Calendar.DAY_OF_MONTH), HOUR_END_ROLLING, MINUTE_END_ROLLING); if (DEBUG) Log.d(TAG, "now=" + date.getTime()); ... |
boolean | isAfterRollingTimeOut(Calendar date) Check if current time is after 19h45 Calendar today = getCalendar(); today.setTime(date.getTime()); Calendar endRollingTime = getCalendar(today.get(Calendar.YEAR), today.get(Calendar.MONTH), today.get(Calendar.DAY_OF_MONTH), HOUR_ROLLING_TIMEOUT, MINUTE_ROLLING_TIMEOUT); if (DEBUG) Log.d(TAG, "now=" + date.getTime()); ... |
boolean | isBeforeRollingEndTime(Calendar date) Check if current time is before 19h30 Calendar today = getCalendar(); today.setTime(date.getTime()); Calendar endRollingTime = getCalendar(today.get(Calendar.YEAR), today.get(Calendar.MONTH), today.get(Calendar.DAY_OF_MONTH), HOUR_END_ROLLING, MINUTE_END_ROLLING); if (DEBUG) Log.d(TAG, "now=" + date.getTime()); ... |
boolean | isBeforeRollingTime(Calendar date) Check if current time is before 19h15 Calendar today = getCalendar(); today.setTime(date.getTime()); Calendar startRollingTime = getCalendar(today.get(Calendar.YEAR), today.get(Calendar.MONTH), today.get(Calendar.DAY_OF_MONTH), HOUR_START_ROLLING, MINUTE_START_ROLLING); if (DEBUG) Log.d(TAG, "now=" + date.getTime()); ... |
boolean | isSameDay(Calendar calSource, Calendar calDesti) is Same Day if (calSource == null || calDesti == null) { throw new IllegalArgumentException("The date must not be null"); return calSource.get(Calendar.ERA) == calDesti.get(Calendar.ERA) && calSource.get(Calendar.YEAR) == calDesti .get(Calendar.YEAR) && calSource.get(Calendar.DAY_OF_YEAR) == calDesti .get(Calendar.DAY_OF_YEAR); ... |
boolean | isSameInstant(Calendar cal1, Calendar cal2) is Same Instant if (cal1 == null || cal2 == null) { throw new IllegalArgumentException("The date must not be null"); return cal1.getTime().getTime() == cal2.getTime().getTime(); |
boolean | isSameLocalTime(Calendar calSource, Calendar calDesti) is Same Local Time return calSource.equals(calDesti);
|
int | compare(Calendar d1, Calendar d2) compare int result = 0; if (d1 == null && d2 == null) return result; if (d1 == null) return -1; if (d2 == null) return 1; if (d1.after(d2)) ... |