I have a date in string and values like "18,June 2017, 5:39AM" and
"01,July 2017, 9:09AM". Now I want to convert these dates to "2017-06-18 18:47:17" in this format . I have use this code:
String testDate = "18,June 2017, 5:39AM";
SimpleDateFormat formatter = new SimpleDateFormat("dd,MMMM yyyy , HH:mm a", Locale.ENGLISH);
Date date = formatter.parse(testDate);
System.out.println(date);
But I have got an exception:
Exception in thread "main" java.text.ParseException: Unparseable date: "18,June 2017, 5:39AM"
at java.text.DateFormat.parse(DateFormat.java:366)
How can I convert "18,June 2017, 6:47PM" to "2017-06-18 18:47:17"?