We have a huge list which updates daily.
We get daily files multiple times a day with same names and each file has different timestamps (format can be any way but it includes dd,mm,yy hour, minutes, seconds) like:
ABC_2013-07-25T00:00:00
BBC_2013-07-25T01:00:00
ABC_2013-07-25T02:00:00
BBC_2013-07-25T02:00:00
ABC_2013-07-26T00:00:00
BBC_2013-07-26T01:00:00
BBC_2013-07-26T02:00:00
and so on.....
I want to use Java collections and want to get File with latest timestamp for each day like
For 31st latest one are
ABC_2013-07-25T02:00:00
BBC_2013-07-25T02:00:00
For 1st latest one files are
ABC_2013-07-26T00:00:00
BBC_2013-07-26T02:00:00
How can we achieve this easily using Java Collections?
An idea comes into mind is using Collections.sort(), compare and find max but is there any straight forward way in Java collections to achieve this where we do not require manual comparison?