I have 2 lists which are holding the same objects but unordered and I want to sort them first before comparing them in order to check whether they are equals.
One item of each list looks like that:
first list:
AuditRow{dateStr='2019-04-15 11:16', userStr='admin', entityStr='Users'}
second list:
AuditRow{dateStr='2019-04-15 10:28', userStr='admin', entityStr='Users'}
I tried to use Comparator for this issue but with no success I must say that both of the list got more than 10 items.
I want to achieve the goal of sorting up my lists by their date time (mostly relying on hour since the date is the same for all the items).
This is what I tried:
Override
public int compareTo(AuditRow auditRow) {
int compareage = Integer.parseInt(((AuditRow)auditRow).dateStr.replace(" ",""));
return Integer.parseInt(this.dateStr.replace(" ",""))-compareage;
}
But this did not do the trick