问题
I'm using joda-time 1.6.2 in an Android app and I am getting some crash reports
java.lang.IllegalArgumentException: Invalid format: "8:00 AM" is malformed at "AM"
And the code that triggers is is the following:
DateTimeFormatter formatter = DateTimeFormat.forPattern("hh:mm a");
LocalTime lt = formatter.parseDateTime(value).toLocalTime();
I can't reproduce this crash on my phones so it happens only on certain Android devices and I have no clue why.
回答1:
I was faced with the same issue after the release of Android 5. Only devices running this version would crash.
This is probably a localization issue. It appears that your default local does not know the "AM"-string, but something else.
See my post for details and my solution
来源:https://stackoverflow.com/questions/13286127/joda-time-bug-on-certain-android-devices