I am trying to order some arraylist from newest date to oldest date using comparator. But I can`t seem to get it right, the dates are getting sorted but not from newest to oldest.
Any help is appreciated.
Piece of the code involved:
public class MyFvModel {
...
private long time;
public MyFvModel(String fvName, long fvDate, long id) {
this.fvName = fvName;
this.fvDate = fvDate;
this.id = id;
this.time = System.currentTimeMillis();
}
public long getTime() {
return time;
}
...
public static Comparator<MyFvModel> DateComparator = new Comparator<MyFvModel>() {
public int compare(MyFvModel s1, MyFvModel s2) {
long Date1 = s1.getFvDate();
long curTime = s2.getTime();
if (Date1 < curTime)
return 0;
else
return 1;
}
};
}