Java tutorial
import java.util.Calendar; public class Main { public static void main(String[] args) { Calendar cal1 = Calendar.getInstance(); cal1.set(2015, 2, 27); Calendar cal2 = Calendar.getInstance(); cal2.set(2015, 8, 1); boolean valid = isSixMonthsAgo(cal1, cal2); System.out.println(valid); } public static boolean isSixMonthsAgo(Calendar c1, Calendar c2) { int year1 = c1.get(Calendar.YEAR); int month1 = c1.get(Calendar.MONTH); int year2 = c2.get(Calendar.YEAR); int month2 = c2.get(Calendar.MONTH); if ((year1 * 12 + month1) - (year2 * 12 + month2) > 6) return true; return false; } }