KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > util > CalendarComparator


1 //$Id: CalendarComparator.java,v 1.1 2004/09/04 13:01:55 oneovthafew Exp $
2
package org.hibernate.util;
3
4 import java.util.Calendar JavaDoc;
5 import java.util.Comparator JavaDoc;
6
7 /**
8  * @author Gavin King
9  */

10 public class CalendarComparator implements Comparator JavaDoc {
11
12     public int compare(Object JavaDoc x, Object JavaDoc y) {
13         Calendar JavaDoc xcal = (Calendar JavaDoc) x;
14         Calendar JavaDoc ycal = (Calendar JavaDoc) y;
15         if ( xcal.before(ycal) ) return -1;
16         if ( xcal.after(ycal) ) return 1;
17         return 0;
18     }
19     
20     public static final Comparator JavaDoc INSTANCE = new CalendarComparator();
21
22 }
23
Popular Tags