KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > calipso > reportgenerator > reportcalculator > expression > DateComparator


1 package com.calipso.reportgenerator.reportcalculator.expression;
2
3 import java.util.Comparator JavaDoc;
4 import java.util.Date JavaDoc;
5
6 /**
7  * Compara dos fechas
8  */

9 public class DateComparator implements Comparator JavaDoc {
10   public int compare(Object JavaDoc o1, Object JavaDoc o2) {
11     Date JavaDoc o1Date = (Date JavaDoc)o1;
12     Date JavaDoc o2Date = (Date JavaDoc)o2;
13     if ((o1Date).before(o2Date)){
14       return -1;
15     }else if (o1Date.getTime()== o2Date.getTime()){
16       return 0;
17     }else{
18       return 1;
19     }
20   }
21
22 }
23
Popular Tags