List of utility methods to do Date Compare by Day
boolean | isSameDay(Date lastUpgradeTime) is Same Day Calendar now = Calendar.getInstance(); Calendar lastUpgrade = Calendar.getInstance(); lastUpgrade.setTime(lastUpgradeTime); if (now.get(Calendar.DATE) == lastUpgrade.get(Calendar.DATE)) { return true; return false; |
boolean | isSameDay(final Date date1, final Date date2) Returns true if both of the dates represent the same day. return isSameDay(date1.getTime(), date2.getTime());
|
boolean | isSameDayWithToday(Date date) is Same Day With Today if (date == null) { return false; Calendar todayCal = Calendar.getInstance(); Calendar dateCal = Calendar.getInstance(); todayCal.setTime(new Date()); dateCal.setTime(date); int subYear = todayCal.get(Calendar.YEAR) - dateCal.get(Calendar.YEAR); ... |
boolean | sameDay(Date date1, Date date2) same Day Calendar cal1 = Calendar.getInstance(); Calendar cal2 = Calendar.getInstance(); cal1.setTime(date1); cal2.setTime(date2); int date1Year = cal1.get(Calendar.YEAR); int date1Month = cal1.get(Calendar.MONTH) + 1; int date1Day = cal1.get(Calendar.DATE); int date2Year = cal2.get(Calendar.YEAR); ... |
boolean | sameDay(Date date1, Date date2) Whether the two date are on the same day Calendar calendar1 = Calendar.getInstance();
Calendar calendar2 = Calendar.getInstance();
calendar1.setTime(date1);
calendar2.setTime(date2);
return (calendar1.get(Calendar.DAY_OF_YEAR) == calendar2.get(Calendar.DAY_OF_YEAR))
&& (calendar1.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR));
|
boolean | sameDay(Date date1, Date date2) same Day if (date1 == null || date2 == null) { return false; Calendar cal1 = Calendar.getInstance(); Calendar cal2 = Calendar.getInstance(); cal1.setTime(date1); cal2.setTime(date2); boolean sameDay = cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) ... |
boolean | sameDay(Date date1, Date date2) same Day Calendar c1 = new GregorianCalendar(); Calendar c2 = new GregorianCalendar(); c1.setTime(date1); c2.setTime(date2); return c1.get(Calendar.DAY_OF_YEAR) == c2.get(Calendar.DAY_OF_YEAR); |
boolean | sameDay(Date dateOne, Date dateTwo) Test to see if two dates are in the same day of year if ((dateOne == null) || (dateTwo == null)) { return false; Calendar cal = Calendar.getInstance(); cal.setTime(dateOne); int year = cal.get(Calendar.YEAR); int day = cal.get(Calendar.DAY_OF_YEAR); cal.setTime(dateTwo); ... |
boolean | sameDay(Date t1, Date t2) same Day c1.setTime(t1);
c2.setTime(t2);
return (c1.get(Calendar.YEAR) == c2.get(Calendar.YEAR))
&& (c1.get(Calendar.MONTH) == c2.get(Calendar.MONTH))
&& (c1.get(Calendar.DAY_OF_MONTH) == c2.get(Calendar.DAY_OF_MONTH));
|
boolean | sameDay(Date t1, Date t2, TimeZone tz) Determines if the two dates are in the same day in the given time zone. Calendar cal1 = new GregorianCalendar(tz); cal1.setTime(t1); Calendar cal2 = new GregorianCalendar(tz); cal2.setTime(t2); return cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) && cal1.get(Calendar.MONTH) == cal2.get(Calendar.MONTH) && cal1.get(Calendar.DAY_OF_MONTH) == cal2.get(Calendar.DAY_OF_MONTH); |