Here you can find the source of isSameMonth(Timestamp t1, Timestamp t2)
public static boolean isSameMonth(Timestamp t1, Timestamp t2)
//package com.java2s; import java.sql.Timestamp; import java.util.Calendar; public class Main { public static boolean isSameMonth(Timestamp t1, Timestamp t2) { Calendar cal = Calendar.getInstance(); cal.setTime(t1);/* w w w . j a v a2 s . c om*/ int year1 = cal.get(Calendar.YEAR); int month1 = cal.get(Calendar.MONTH); System.out.println("year1:" + year1 + "month1:" + month1); cal.setTime(t2); int year2 = cal.get(Calendar.YEAR); int month2 = cal.get(Calendar.MONTH); System.out.println("year2:" + year2 + "month2:" + month2); if (year1 == year2 && month1 == month2) return true; return false; } }