Java Utililty Methods Date Compare by Hour

List of utility methods to do Date Compare by Hour

Description

The list of methods to do Date Compare by Hour are organized into topic(s).

Method

booleansameHour(Date date1, Date date2)
same Hour
Calendar c1 = Calendar.getInstance();
Calendar c2 = Calendar.getInstance();
c1.setTime(date1);
c2.setTime(date2);
return c1.get(Calendar.YEAR) == c2.get(Calendar.YEAR)
        && c1.get(Calendar.DAY_OF_YEAR) == c2.get(Calendar.DAY_OF_YEAR)
        && c1.get(Calendar.HOUR_OF_DAY) == c2.get(Calendar.HOUR_OF_DAY);
booleansameHour(Date dateOne, Date dateTwo)
Test to see if two dates are in the same hour of day
if ((dateOne == null) || (dateTwo == null)) {
    return false;
Calendar cal = Calendar.getInstance();
cal.setTime(dateOne);
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH);
int day = cal.get(Calendar.DAY_OF_YEAR);
...