Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java SimpleDateFormat am/pm

I get an Date with format: MM-dd-yy hhmma zzz. The problem is that i only get an A for AM or P for PM. How can I parse a string with that format to a date object?

  • Alex
like image 400
Alex Haider Avatar asked Aug 26 '26 14:08

Alex Haider


2 Answers

Use this 'a'

example: MM-dd-yy hhmma a;

Visit http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html

like image 62
Muskan Avatar answered Aug 28 '26 03:08

Muskan


This pattern is working for me:

dd-MM-yyyy hh:mm:ss a

It prints the information in this format: 12-02-2016 03:50:07 PM

like image 25
Rene Enriquez Avatar answered Aug 28 '26 05:08

Rene Enriquez



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!