JodaTime does not recognize some Android time zones

I use JodaTime in my application and I get reports from the developer console about crashes like this:

java.lang.RuntimeException: Unable to resume activity {com.myapp.app/Home}: java.lang.IllegalArgumentException: The datetime zone id 'Africa/Abuja' is not recognised
....
Caused by: java.lang.IllegalArgumentException: The datetime zone id 'Africa/Abuja' is not recognised
at org.joda.time.DateTimeZone.forTimeZone(DateTimeZone.java:337)
...

I use this line of code to get Timezone:

DateTimeZone tz = DateTimeZone.forTimeZone(TimeZone.getDefault());

Interestingly, most failures Africa/****.

TimeZone.getDefault() is part of the Android API, so I assumed that it will return the used timezone identifiers.

Is there anything I can do with these time zones to use them correctly? Is this a known issue with Android and Joda Time?

+4
source share
2 answers

Use this adapted Android version of Joda: https://github.com/dlew/joda-time-android

JodaTimeAndroid.init(this); onCreate ( ), voilà, , .

+8

"/" IANA-tz ( ). "/".

, JodaTime IANA ( ), Android tz, . android-api-link Android Olson-tz-identifiers. , "/" . . TimeZone.getAvailableIDs()?

- Android TimeZone.getDefault() "Africa/Abuja", "user.timezone" "Africa/Lagos". JodaTime .

+1

Source: https://habr.com/ru/post/1532432/


All Articles