Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"EEEE, MMMM d, yyyy 'at' HH:mm"

I am trying to convert from string to date. An example is : Wednesday, September 4, 2013 at 5:07pm

I first convert it to: Wednesday, September 4, 2013 at 5:07 PM

And use the following code:

SimpleDateFormat format = new SimpleDateFormat("EEEE, MMMM d, yyyy 'at' hh:mm a");

But I always get the Unparseable date Exception.

Any help is appreciated!

like image 573
andi-andi Avatar asked Oct 04 '22 00:10

andi-andi


1 Answers

The following works for me:

String str = "Wednesday, September 4, 2013 at 5:07 PM";
SimpleDateFormat format = new SimpleDateFormat("EEEE, MMMM d, yyyy 'at' hh:mm a", Locale.US);

But if I remove the Locale, then I get a ParseException. Your computer Locale corresponds probably not to a english speaking locale.

like image 68
LaurentG Avatar answered Oct 08 '22 01:10

LaurentG