Here you can find the source of compare(Calendar c1, Calendar c2)
public static int compare(Calendar c1, Calendar c2)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { public static int compare(Calendar c1, Calendar c2) { if (c1 == null || c2 == null) return -1; long r = c1.getTimeInMillis() - c2.getTimeInMillis(); if (r > 0) return 1; else if (r == 0) return 0; else//from ww w . j a v a2 s. c o m return 2; } public static int compare(Date c1, Date c2) { if (c1 == null || c2 == null) return -1; long r = c1.getTime() - c2.getTime(); if (r > 0) return 1; else if (r == 0) return 0; else return 2; } }