0

I am trying to parse a date string "2016-06-17 15:42:20" using DateFormat.parse() and I am getting and Exception reported:

java.text.ParseException: Unparseable date: ""2016-06-17 15:42:20""
    at java.text.DateFormat.parse(DateFormat.java:357)

What is wrong with this Date string? I am using the format yyyy-MM-dd HH:mm:ss in my call.

Thanks for the help.

Svetlin Zarev
  • 14,713
  • 4
  • 53
  • 82
  • please paste the particular section of your code – Abhijit Chowdhury Aug 19 '16 at 16:29
  • 1
    It seems that you have some quotes in the date string. Remove them – Svetlin Zarev Aug 19 '16 at 16:40
  • Duplicates: [Parse Date String to Some Java Object](http://stackoverflow.com/q/8854780/642706) & [Parse a date from a string](http://stackoverflow.com/q/36441504/642706) & [How to extract date and time from a String Timestamp in java](http://stackoverflow.com/q/21796497/642706) & [How to split full date format in date and time - java](http://stackoverflow.com/q/37390405/642706) and more. Please search Stack Overflow before posting. – Basil Bourque Aug 19 '16 at 18:16

2 Answers2

0

note this:

java.text.ParseException: Unparseable date: ""2016-06-17 15:42:20""
                                             ^-------------------^

Your date already has quotes around it, which aren't present in your format string. Probably you want parse(date, "\"yyyy-mm-dd hh:mm:ss\"" or similar.

Marc B
  • 356,200
  • 43
  • 426
  • 500
0
If input date String and from user format is different then java throws this error

enter image description here

make sure input date string format is same as the form user simple date format.

enter image description here