GithubHelp home page GithubHelp logo

seekingforever / joda-time-android Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dlew/joda-time-android

0.0 1.0 0.0 2.44 MB

Joda-Time library with Android specialization

License: Apache License 2.0

Groovy 5.09% Java 92.77% Python 2.14%

joda-time-android's Introduction

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 {
    compile 'net.danlew:android.joda:2.9.9'
}

Once that's done, you must initialize the library before using it by calling JodaTimeAndroid.init(). I suggest putting this code in Application.onCreate():

public class MyApp extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        JodaTimeAndroid.init(this);
    }
}

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 thoses 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'
    }
}

joda-time-android's People

Contributors

dlew avatar rlac avatar gfx avatar scottdweber avatar artem-zinnatullin avatar hamen avatar lucasxas avatar elevenfive avatar raskasa avatar plastiv avatar vladad avatar josiahneuberger avatar ligi avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.