Here you can find the source of isSameMonth(final Date date1, final Date date2)
public static boolean isSameMonth(final Date date1, final Date date2)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { public static boolean isSameMonth(final Date date1, final Date date2) { final Calendar cal1 = Calendar.getInstance(); cal1.setTime(date1);// ww w .j ava 2 s. co m final Calendar cal2 = Calendar.getInstance(); cal2.setTime(date2); if (cal1.get(Calendar.YEAR) != cal2.get(Calendar.YEAR)) { return false; } return cal1.get(Calendar.MONTH) == cal2.get(Calendar.MONTH); } }