Here you can find the source of compare(Calendar d1, Calendar d2)
public static int compare(Calendar d1, Calendar d2)
//package com.java2s; import java.util.Calendar; public class Main { public static int compare(Calendar d1, Calendar d2) { int result = 0; if (d1 == null && d2 == null) return result; if (d1 == null) return -1; if (d2 == null) return 1; if (d1.after(d2)) result = 1;//from w ww . j a v a2 s .co m else if (d1.before(d2)) result = -1; else result = 0; return result; } }