Here you can find the source of yearMonthsEqual(final Date firstDate, final Date secondDate)
public static boolean yearMonthsEqual(final Date firstDate, final Date secondDate)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.Date; public class Main { public static boolean yearMonthsEqual(final Date firstDate, final Date secondDate) { final Calendar firstCal = Calendar.getInstance(); firstCal.setTime(firstDate);/*from w w w. java 2 s . c o m*/ final Calendar secondCal = Calendar.getInstance(); secondCal.setTime(secondDate); return firstCal.get(Calendar.MONTH) == secondCal.get(Calendar.MONTH) && firstCal.get(Calendar.YEAR) == secondCal.get(Calendar.YEAR); } }