1 22 package com.geinuke.util.collection; 23 24 import java.util.Comparator ; 25 26 import com.geinuke.vo.NewsVO; 27 28 29 30 public class NewsComparator implements Comparator { 31 public static int ASC=0; 32 public static int DESC=0; 33 protected int ord=-1; 34 35 public NewsComparator(){ 36 super(); 37 this.ord=DESC; 38 } 39 40 public NewsComparator(int o){ 41 super(); 42 this.ord=o; 43 } 44 45 public int compare(Object first, Object second) { 46 NewsVO f=(NewsVO)first; 47 NewsVO s=(NewsVO)second; 48 if(this.ord==DESC) 49 return (new Long (s.getTime())).compareTo( new Long (f.getTime()) ); 50 else 51 return (new Long (f.getTime())).compareTo( new Long (s.getTime()) ); 52 } 53 } 54 | Popular Tags |