As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
you can modify the implementation of getPressReleases (in Util.java) to sort the collection before returning it.
Collections.sort(result, new Comparator() { public int compare(PressReleaseBean prb1, PressReleaseBean prb2) { return prb1.getLaunchDate().compare(prb2.getLaunchDate()); } });
at the end of getPressReleases in Util.java add: Collections.sort(result, new Comparator() { public int compare(PressReleaseBean prb1, PressReleaseBean prb2) { return prb1.getLaunchDate().compare(prb2.getLaunchDate()); } }); see http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collections.html for more information on how to sort lists.
G:\noviweb>javac Util.java Util.java:56: <cryptonym org.alfresco.web.pr.Util$1>not abstract,and not cover with java.util .abstract method of Comparator compare(java.lang.Object,java.lang.Object) public int compare(PressReleaseBean prb1, PressReleaseBean prb2) { ^ Util.java:57: not find symbol symbol: method compare(java.util.Date) location: class java.util.Date return prb1.getLaunchDate().compare(prb2.getLaunchDate()); ^ advert: want to know particular information,please use -Xlint:unchecked afresh javac。 2 errors
Collections.sort(result, new Comparator() { public int compare(Object o1, Object o2) { return ((PressReleaseBean)o1).getLaunchDate().compareTo(((PressReleaseBean)o2).getLaunchDate()); } });
the method on Date is compareTo, not compare. my mistake.what version of the jdk are you using? the code i'm providing is for jdk1.5.if you are using an older jdk this should work. Collections.sort(result, new Comparator() { public int compare(Object o1, Object o2) { return ((PressReleaseBean)o1).getLaunchDate().compareTo(((PressReleaseBean)o2).getLaunchDate()); } });