Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Joda time bug on certain Android devices?

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.

like image 270
Catalin Morosan Avatar asked Mar 11 '26 04:03

Catalin Morosan


1 Answers

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

like image 178
magnarwium Avatar answered Mar 12 '26 17:03

magnarwium