Oracle ATG Code – Sorting the Repository Items

Oracle ATG Code – Sorting the Repository Items based on the Date

Oracle ATG Code – Sorting the Repository Items based on the Date using Comparator and Collections – reverse Order.

A comparison function, imposes a total ordering on a object collection. Comparators is used to control the order of certain data structures or to provide an ordering for collections of objects which don’t have a natural ordering.

Oracle ATG Code - Sorting


private List <RepositoryItem> stixsSortItemsByLastUpdateDate(List <RepositoryItem> items) {
Collections.sort(items, Collections.reverseOrder(new Comparator < RepositoryItem > () {

public int compare(RepositoryItem repItem1, RepositoryItem repItem2) {
int retValue = 1;
Timestamp t1 = new Timestamp(System.currentTimeMillis());
Timestamp t2 = new Timestamp(System.currentTimeMillis());

t1 = (Timestamp) o1.getPropertyValue(ProfileConstants.P_PROFILE_LAST_LOGIN_DATE);
t2 = (Timestamp) o2.getPropertyValue(ProfileConstants.P_PROFILE_LAST_LOGIN_DATE);

Date date1 = new Date(t1.getTime());
Date date2 = new Date(t2.getTime());

if (date1.before(date2)) {
retValue = 1;

if (date1.after(date2)) {
retValue = -1;
if (date1.equals(date2)) {
retValue = 0;

return retValue;
return items;


You may also like this



Personalization related tables in Oracle ATG

ORACLE ATG ENDECA & JAVA TECHNOLOGY XCHANGE SYSTEM. is a dedicated weblog for Oracle ATG, Oracle Endeca, Java/J2EE and web developers. We take pride in our work. Every publication is carefully analyzed, written and tested to ease the understanding of the topic or subject.

We cover Oracle ATG, Oracle Endeca, Java Core Technologies, eCommerce, J2EE Frameworks, Web Service, Build Tools, Unit Test Frameworks and Others.

Subsidiary of  Simplifi Commerce (

SimplifiCommerce Header

At Simplifi Commerce We train individual resource and their organization, to learn & operate efficiently the Oracle Commerce Platform – ATG, Endeca & WebCenter.

Email us at, for a free introductory session.


1,489 total views, 3 views today

Add comment