Chrometobia Chrometobia - 2 years ago 102
Java Question

Parsing date string

I am trying to parse a formatted date back to a Date object but I keep encountering exceptions, here is my code:

DateFormat dateFormat = new SimpleDateFormat("MMMM d, yyyy ", Locale.ENGLISH);
date = dateFormat.parse(dateString);


When I try a date like
Apr 17, 2016
it gives me an
ParserException
to say
Unparseable date: "Apr 17, 2016" (at offset 12)

Answer Source

Try as follows

DateFormat dateFormat = new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH);

Date date = dateFormat.parse(dateString);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download