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