Reputation: 8916
I'm using Joda library for formatting strings like hh:mm am/pm
to LocalTime
in my android app, So I'm using this:
DateTimeFormat.forPattern("hh:mm a").parseLocalTime("6:30 AM");
It works fine, But when I change my phone language (to germany or spanish) it throwns this exception:
W/System.err﹕ java.lang.IllegalArgumentException: Invalid format: "06:30 AM" is malformed at "AM"
Any Ideas?
Upvotes: 2
Views: 1886
Reputation:
Try this using locale English:
DateTimeFormat.forPattern("hh:mm a").withLocale(Locale.ENGLISH).parseLocalTime("6:30 AM");
Upvotes: 7
Reputation: 2727
Try:
DateTimeFormat.forPattern("h:mm aa").parseLocalTime("6:30 AM");
Upvotes: 0