Load your string into a Comparable object:
class Task implements Comparable<Task> {
private Date date;
private String task;
Task (String taskString) {
int splitPoint = 45;
try {
this.date =
DateFormat.getInstance().
parse(taskString.substring(0, splitPoint));
} catch (ParseException ex) {
this.date = new Date();
}
this.task = taskString.substring(splitPoint);
}
public int compareTo(Task o) {
int compare = this.date.compareTo(o.date);
if (compare == 0) {
compare = this.task.compareTo(o.task);
}
return compare;
}
}
Then put this into a
ArrayList
. These are ordered using
Collections.sort
.