Java examples for java.util:Date Compare
compare Calendar Dates
//package com.java2s; import java.util.Calendar; public class Main { public static void main(String[] argv) throws Exception { Calendar cal1 = Calendar.getInstance(); Calendar cal2 = Calendar.getInstance(); System.out.println(compareCalendarDates(cal1, cal2)); }/*from ww w.j a v a2s .c o m*/ public static boolean compareCalendarDates(Calendar cal1, Calendar cal2) { System.out.println("Year--Cal1:" + cal1.get(Calendar.YEAR) + "--Cal2:" + cal2.get(Calendar.YEAR)); System.out.println("Day--Cal1:" + cal1.get(Calendar.DAY_OF_YEAR) + "--Cal2:" + cal2.get(Calendar.DAY_OF_YEAR)); return cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) && cal1.get(Calendar.DAY_OF_YEAR) == cal2 .get(Calendar.DAY_OF_YEAR); } }