Q:

How to parse 2019-02-17T18:39:03?

I looking for a solution to parse the String date.
 datestring.add("2019-02-17T18:39:02");
 datestring.add("2019-02-17T18:39:01");
 datestring.add("2019-02-17T18:39:03");
 datestring.add("2019-02-17T18:39:07");

datastring is the ArrayList of String date.
  Collections.sort(datestring, new Comparator<String>() {
        DateFormat f = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss a");

        @Override
        public int compare(String o1, String o2) {
            try {
                return f.parse(o1).compareTo(f.parse(o2));
            } catch (ParseException e) {
                throw new IllegalArgumentException(e);
            }
        }
    });

So here i am trying to sort the list based on date.
But I am getting ParseException:-
Caused by: java.lang.IllegalArgumentException: java.text.ParseException: Unparseable date: "2019-02-17T18:39:07"

A:

Your incoming date is in format yyyy-MM-dd'T'hh:mm:ss and the format you are using is dd-MMM-yyyy HH:mm:ss a which will not generate error. 
Try parsing your incoming date string using yyyy-MM-dd'T'hh:mm:ss and then convert it to some other format if you want.

