List of utility methods to do Date Before
boolean | before(Date point, Date when) Returns true if the given from Date is before the given when Date otherwise false. final Calendar pointCalendar = Calendar.getInstance(); pointCalendar.setTime(point); final Calendar whenCalendar = Calendar.getInstance(); whenCalendar.setTime(when); return pointCalendar.before(whenCalendar); |
boolean | before(Date sDate, Date eDate) before Calendar sCal = new GregorianCalendar(); sCal.setTime(sDate); Calendar eCal = new GregorianCalendar(); eCal.setTime(eDate); return sCal.before(eCal); |
boolean | beforeDay(final Date date1, final Date date2) Get date one day before specified one. if (date1 == null) return true; return getStartOfDate(date1).before(getStartOfDate(date2)); |
boolean | beforeDays(Date date, Integer days) before Days if (date == null || days == null) return false; Long time = System.currentTimeMillis() - date.getTime(); return time < (days * 86400000); |
boolean | beforeTime(Date time1, Date time2) before Time Calendar calendar1 = Calendar.getInstance();
calendar1.setTime(time1);
Calendar calendar2 = Calendar.getInstance();
calendar2.setTime(time2);
return calendar1.before(calendar2);
|
int | daysBefore(Date date1) days Before Calendar cal = Calendar.getInstance(); cal.setTime(date1); long time1 = cal.getTimeInMillis(); long time2 = System.currentTimeMillis(); long between_days = (time2 - time1) / (1000 * 3600 * 24); return Integer.parseInt(String.valueOf(between_days)); |
Date | getBefore(Date date) get Before return getBefore(date, -1);
|
Calendar | getBeforeDate(final int unit, final int period) get Before Date Calendar deleteTimeCalendar = Calendar.getInstance();
deleteTimeCalendar.add(unit, -1 * period);
return deleteTimeCalendar;
|
Date | getBeforeDate(String range) get Before Date Calendar today = Calendar.getInstance(); if ("week".equalsIgnoreCase(range)) today.add(4, -1); else if ("month".equalsIgnoreCase(range)) today.add(2, -1); else today.clear(); return today.getTime(); ... |
Date | getBeforeHourByCurrentTime(Date now, int mount) get Before Hour By Current Time Calendar c = Calendar.getInstance();
c.setTime(now);
c.set(Calendar.HOUR_OF_DAY, c.get(Calendar.HOUR_OF_DAY) + mount);
return c.getTime();
|