I have a timestamp string like this:
2016-01-14T22:43:55Z
2016-01-15T00:04:50Z
2016-01-15T00:44:59+08:30
2016-01-15T01:25:35-05:00
2016-01-15T01:44:31+08:30
2016-01-15T02:22:45-05:00
2016-01-15T02:54:18-05:00
2016-01-15T03:53:26-05:00
2016-01-15T04:32:24-08:00
2016-01-15T06:31:32Z
2016-01-15T07:06:07-05:00
I want to sort them so that I can get what is starting range and ending range from above timestamp. I am doing like below:
List<String> timestamp = new ArrayList<>();
// adding above string timestamp into this list
// now sort it
Collections.sort(timestamp);
This will give me start and end range from the above list of timestamp. Is this the right way to do it or there is any better way?
timestamp.get(0); // start range
timestamp.get(timestamp.size() - 1); // end range
Update
So I should do something like below:
List<OffsetDateTime> timestamp = new ArrayList<>();
timestamp.add(OffsetDateTime.parse( "2016-01-15T00:44:59+08:30" ));
// add other timestamp string like above and then sort it
Collections.sort(timestamp);
timestamp.get(0); // start range
timestamp.get(timestamp.size() - 1); // end range