• Stars
    star
    2,626
  • Rank 17,436 (Top 0.4 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created almost 11 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Joda-Time library with Android specialization

joda-time-android

This library is a version of 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.

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 their timezones all the time; 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(), it greatly inflates its memory footprint on apps. (For more details, see this blog post.) 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, a port of Android's DateUtils.

Usage

Add the following dependency to build.gradle:

dependencies {
    implementation 'net.danlew:android.joda:2.12.5'
}

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:

<provider
    android:name="androidx.startup.InitializationProvider"
    android:authorities="${applicationId}.androidx-startup"
    android:exported="false"
    android:process="[your-process-name-here]"
    tools:node="merge" />

Alternatively, you can call AppInitializer directly to initialize just joda-time-android:

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 excludes 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 merges in your build.gradle file and you will be good to go:

android {
    ...
    packagingOptions {
        merge '**/LICENSE.txt'
        merge '**/NOTICE.txt'
    }
}

More Repositories

1

android-architecture-counter-sample

Sample app using Android architecture components
Kotlin
633
star
2

rxjava-multiple-sources-sample

Sample code demonstrating loading multiple data sources via RxJava
Java
471
star
3

android-gfycat

Android application that loads gifs via gfycat for efficiency's sake
Java
359
star
4

android-movies-demo

Sample application demonstrating Android design and animation
Java
358
star
5

android-gridlayout

A backwards compatible implementation of GridLayout for Android
Java
186
star
6

android-subscription-leaks

Small sample app demonstrating memory leak solutions when using RxJava
Java
159
star
7

android-hw-layers-sample

Sample project showing how to use hardware layers for great good
Java
65
star
8

aoc-2017

Advent of Code 2017
Kotlin
51
star
9

android-ragefaces

Silly Android application for sharing rage faces with other apps
Java
31
star
10

android-quickmap

Quick contacts list --> directions app
Java
21
star
11

android-download-shortcut

Adds "download" option when sharing files on Android
Java
17
star
12

android-shared-test-module-example

Example of sharing a test module between multiple types of tests/modules
Kotlin
15
star
13

android-utils

My own set of utils for Android applications
Java
15
star
14

android-mvc-demo

Java
14
star
15

android-custom-views-sample

Sample code for the talk "Custom Views for Profit and Pleasure"
Java
13
star
16

wordle-solver

Evaluates the efficacy of Wordle algorithms
Kotlin
12
star
17

aoc-2016

Advent of Code (2016)
Kotlin
12
star
18

android-headset-blocker

Java
11
star
19

android-svg-drawable-test

Testing performance of SVGs vs bitmaps
Java
10
star
20

android-drawable-xml-demo

Java
9
star
21

android-pseudolocalization-sample

A small sample showing off how pseudolocalization works on Android
Java
8
star
22

android-sotm

Sentinels of the Multiverse helper application
Java
6
star
23

kotlin-riddler

Solving riddles using Kotlin
Kotlin
6
star
24

android-whogoesfirst

Simple app for determining who goes first (especially in the context of board gaming)
Java
5
star
25

android-ripple-drawable-demo

Demo of a small problem with RippleDrawable
Java
5
star
26

android-findviewbyid

Aims to figure out if View.findViewById() is really all that bad
Java
5
star
27

android-resistance

Simple app for the Resistance board game
Java
5
star
28

predictit-bot

PredictIt bot
Kotlin
4
star
29

android-mia

Audio tour guide for Minneapolis Institute of Arts
Java
3
star
30

android-dmmrm

Code examples for talk "don't make me repeat myself"
Java
2
star
31

walgreens-scanner

Scans Walgreens for item stock
Kotlin
2
star
32

hpb

Small tool for finding Half-Price Books at local stores
Kotlin
2
star
33

reddit-mods

Python
2
star
34

displate-inventory-extension

Improves information/display for Displate limited editions
HTML
2
star
35

android-images-sample

Sample app that shows off Google image search
Shell
2
star
36

android-bitmap-retained-demo

Small demo app
Java
1
star
37

census-maps

JavaScript
1
star
38

android-ragefaces-tools

A collection of tools used for maintaining the Android app Rage Faces
Python
1
star
39

android-drawable-hotspots-sample

Sample app demonstrating various issues one can have with Drawable hotspots
Java
1
star