Here you can find the source of isEqualField(int field, Date d1, Date d2)
public static boolean isEqualField(int field, Date d1, Date d2)
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public static boolean isEqualField(int field, Date d1, Date d2) { Calendar c1 = Calendar.getInstance(); c1.setTime(d1);/* w w w .ja v a 2s .com*/ Calendar c2 = Calendar.getInstance(); c2.setTime(d2); return c1.get(field) == c2.get(field); } public static int get(int field, Date date) { Calendar c = Calendar.getInstance(); c.setTime(date); return c.get(field); } }