Sort Arraylist With Times [duplicate]

Lets start here:

} catch (ParseException e) {
    return 0;
}

ParseException means parsing went wrong. You are suppressing that and turn it into: the two strings equal the same time.

Simply don’t do that.

Then I would also suggest to not store strings, but Date objects in that list. You have to understand that each and any compare causes those formatting steps. In other words, sorting on strings instead of dates causes an enormous overhead here!

In other words, turn all strings into dates first and then sort the dates.

Browse More Popular Posts

Leave a Comment