| 1 25 package com.j2biz.blogunity.util; 26 27 import java.io.Serializable ; 28 import java.util.Comparator ; 29 30 import com.j2biz.blogunity.exception.BlogunityRuntimeException; 31 import com.j2biz.blogunity.i18n.I18N; 32 import com.j2biz.blogunity.i18n.I18NStatusFactory; 33 import com.j2biz.blogunity.pojo.Comment; 34 35 42 public class CommentComparator implements Comparator ,Serializable { 43 44 47 private static final long serialVersionUID = 3834594287970301240L; 48 49 54 public int compare(Object o1, Object o2) { 55 try { 56 Comment c1 = (Comment) o1; 57 Comment c2 = (Comment) o2; 58 59 return (int) (c1.getCreateTime().getTime() - c2.getCreateTime().getTime()); 60 61 } catch (Exception e) { 62 throw new BlogunityRuntimeException(I18NStatusFactory.create( 63 I18N.ERRORS.UNABLE_TO_COMPARE, new String []{"comments"}, e)); 64 } 65 } 66 } | Popular Tags |