I'm new to java and I'm getting problem parsing this date: "12/19/2015 8:00:00 AM".
Asked
Active
Viewed 74 times
-7
-
Have you tried
? – Arc676 Dec 19 '15 at 09:46 -
which format do you expect? – Abdelhak Dec 19 '15 at 09:47
-
What is the problem that you are getting? – khelwood Dec 19 '15 at 09:49
-
can you tell which format you want convert – soorapadman Dec 19 '15 at 09:50
-
(The duplicate isn't for the exact format, but it should be enough to get you started.) – Jon Skeet Dec 19 '15 at 09:50
1 Answers
0
Just follow the documentation and use the formatting elements that correspond to the string you have:
String strDate = "12/19/2015 8:00:00 AM";
DateFormat df = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a");
Date date = df.parse(strDate);

Mureinik
- 297,002
- 52
- 306
- 350