Java Utililty Methods Date Compare by Year

List of utility methods to do Date Compare by Year

Description

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

Method

booleansameYear(Date date1, Date date2)
Checks if the two given date have the same year.
if (date1 == null || date2 == null) {
    return false;
return getYear(date1) == getYear(date2);
booleansameYear(Date date1, Date date2)
same Year
if (date1 == null || date2 == null) {
    return false;
Calendar calendar = Calendar.getInstance();
calendar.setTime(date1);
Calendar calendar2 = Calendar.getInstance();
calendar.setTime(date2);
return calendar.get(Calendar.YEAR) - calendar.get(Calendar.YEAR) == 0;
...