Skip to content

JakeWharton/ThreeTenABP

Repository files navigation

ThreeTen Android Backport

An adaptation of the JSR-310 backport for Android.

Attention: Development on this library is winding down. Please consider switching to Android Gradle plugin 4.0, java.time.*, and its core library desugaring feature in the coming months.

Usage

Initialize the timezone information in your Application.onCreate() method:

@Override public void onCreate() {
  super.onCreate();
  AndroidThreeTen.init(this);
}

That's it. Otherwise usage is the exact same as the ThreeTenBP library and you should consult its website for usage information: https://www.threeten.org/threetenbp/.

Why JSR-310?

JSR-310 was included in Java 8 as the java.time.* package. It is a full replacement for the ailing Date and Calendar APIs in both Java and Android. JSR-310 was backported to Java 6 by its creator, Stephen Colebourne, from which this library is adapted.

Why not use ThreeTenBP?

Similar to the problems with using Joda-Time on Android, the threetenbp uses a JAR resource for loading timezone information. This is an extremely inefficient mechanism on Android.

This library places the timezone information as a standard Android asset and provides a custom loader for parsing it efficiently.

Why not use Joda-Time?

Joda-Time has a very large API which brings with it a very large binary size and large method count. The creator of both JSR-310 and Joda-Time has also said that while Joda-Time isn't broken, it does have design flaws.

If you are using Joda-Time already, there's little reason to switch unless its size or method count is relevant to you. For new projects, however, this library offers the standard APIs in Java 8 as a much smaller package in not only binary size and method count, but also in API size.

Download

implementation 'com.jakewharton.threetenabp:threetenabp:1.4.8'

Snapshots of the development version are available in Sonatype's snapshots repository.

License

Copyright (C) 2015 Jake Wharton

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

An adaptation of the JSR-310 backport for Android.

Resources

License

Stars

Watchers

Forks