I wanted to get a java.util.Date
Object by parsing a String date : "2017-06-28 08:30 AM". This parsing is used in my Android application. This is working without any parsing exception in many Android
versions. Like 7.0, 4.4.2 and 5.1. But this is not working in Android
6.0.
This is my error log and SimpleDateFormat
,
W/System.err: java.text.ParseException: Unparseable date: "2017-06-28 08:30 AM" (at offset 17)
at java.text.DateFormat.parse(DateFormat.java:579)
at biz.spsolutions.peopleedge.RosterClockInActivity.setData(RosterClockInActivity.java:531)
at biz.spsolutions.peopleedge.RosterClockInActivity.onCreate(RosterClockInActivity.java:391)
at android.app.Activity.performCreate(Activity.java:6877)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3208)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3351)
at android.app.ActivityThread.access$1100(ActivityThread.java:222)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1796)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7230)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
And This is my SimpleDateFormat
,
SimpleDateFormat currentFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm a")
Also I have tried in this format too,
SimpleDateFormat currentFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm aaa")
How can I handle this exception ? Have any ideas ?