Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dlew/joda-time-android
Joda-Time library with Android specialization
https://github.com/dlew/joda-time-android
Last synced: 4 days ago
JSON representation
Joda-Time library with Android specialization
- Host: GitHub
- URL: https://github.com/dlew/joda-time-android
- Owner: dlew
- License: apache-2.0
- Created: 2014-01-08T19:11:09.000Z (about 11 years ago)
- Default Branch: main
- Last Pushed: 2024-09-19T00:21:50.000Z (4 months ago)
- Last Synced: 2025-01-14T17:40:15.114Z (11 days ago)
- Language: Java
- Size: 3.82 MB
- Stars: 2,625
- Watchers: 61
- Forks: 183
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-android - Joda-Time Android - Joda-Time library with Android specialization. (Libraries / Date & Time)
- awesome-android-libraries - Joda Time Android - time-android | [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) (Other)
- awesome-android-libraries - Joda Time Android - Time library with Android specialization (Time)
- awesome-android-person - joda-time-android
- awesome-android - Joda-Time Android - Joda-Time library with Android specialization. (Libraries / Date & Time)
- awesome-android-libraries - Joda Time Android - time-android | [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) (Other)
- awesome - joda-time-android - Joda-Time library with Android specialization (etc)
- awesome - joda-time-android - Joda-Time library with Android specialization (etc)
README
joda-time-android
=================This library is a version of [Joda-Time](https://github.com/JodaOrg/joda-time) built with Android in mind.
Why Joda-Time?
==============Android has built-in date and time handling - why bother with a library? If you've worked with Java's Date and Calendar classes you can probably answer this question yourself, but if not, check out [Joda-Time's list of benefits](http://www.joda.org/joda-time/#Why_Joda-Time).
For Android developers Joda-Time solves one critical problem: stale timezone data. Built-in timezone data is only updated when the OS is updated, and we all know how often that happens. [Countries modify](http://www.bbc.co.uk/news/world-europe-15512177) [their timezones](http://www.heraldsun.com.au/news/breaking-news/samoa-to-move-the-international-dateline/story-e6frf7jx-1226051660380) [all the](http://www.indystar.com/apps/pbcs.dll/article?AID=/20070207/LOCAL190108/702070524/0/LOCAL) [time](http://uk.reuters.com/article/oilRpt/idUKBLA65048420070916); being able to update your own tz data keeps your app up-to-date and accurate.
Why This Library?
=================I know what you are thinking: Joda-Time is a great library and it's just a single JAR, so why make things more complex by wrapping it in an Android library?
There is a particular problem with the JAR setup on Android: due to its usage of [ClassLoader.getResourceAsStream()](http://developer.android.com/reference/java/lang/ClassLoader.html#getResourceAsStream%28java.lang.String%29), it greatly inflates its memory footprint on apps. (For more details, see [this blog post](http://blog.danlew.net/2013/08/20/joda_time_s_memory_issue_in_android/).) This library avoids the problem for Android by loading from resources instead of a JAR.
This library also has extra utilities designed for Android. For example, see [DateUtils](library/src/main/java/net/danlew/android/joda/DateUtils.java), a port of Android's [DateUtils](http://developer.android.com/reference/android/text/format/DateUtils.html).
Usage
=====Add the following dependency to `build.gradle`:
```groovy
dependencies {
implementation 'net.danlew:android.joda:2.13.0'
}
```Multi-Process Apps
===============Due to using App Startup, joda-time-android will not automatically initialize in non-main processes.
If you would like to automatically run App Startup in other processes, add this to your manifest:
```xml
```
Alternatively, you can call [`AppInitializer`](https://developer.android.com/reference/kotlin/androidx/startup/AppInitializer) directly to initialize just joda-time-android:
```kotlin
AppInitializer.getInstance(this).initializeComponent(JodaTimeInitializer::class.java)
```Troubleshooting
===============
__Q: My build fails with an error about a duplicate file__> Duplicate files copied in APK META-INF/LICENSE.txt
or
> Duplicate files copied in APK META-INF/NOTICE.txt
__A: We can safely exclude those files from our build. You need to specify these two `exclude`s in your `build.gradle` file and you will be good to go:__
```
android {
...
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
```or
__B: We can safely choose to add those files to our build. You need to specify these two `merge`s in your `build.gradle` file and you will be good to go:__
```
android {
...
packagingOptions {
merge '**/LICENSE.txt'
merge '**/NOTICE.txt'
}
}
```