Giter Site home page Giter Site logo

threetenabp's Introduction

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.7'

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.

threetenabp's People

Contributors

baloghtamas avatar davidjwiner avatar drewhamilton avatar egor-n avatar jakewharton avatar jitpack-io avatar mmallozzi avatar mt-mitchell avatar nielsz avatar pengrad avatar teobaranga avatar tobiasschuerg avatar vanniktech avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

threetenabp's Issues

Ship proguard rules in the aar?

Would require:

  • Consensus on rules to include. Ideally would be as limited as possible to allow some stripping to occur, where feasible.
  • Enabling proguard for the instrumentation tests
  • Tests which exercise as much of the API as easily as possible to validate the rules.

Cannot parse time offsets in the form ±[hh][mm] or ±[hh]

DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse("2001-07-04T12:08:56.235-0700");
DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse("2001-07-04T12:08:56.235-07");

and

DateTimeFormatter.ISO_DATE_TIME.parse("2001-07-04T12:08:56.235-0700");
DateTimeFormatter.ISO_DATE_TIME.parse("2001-07-04T12:08:56.235-07");

throw org.threeten.bp.format.DateTimeParseException

Unit testing?

Is Robolectric a requirement for loading a ZoneInfoProvider? Could there be a mechanism for loading such that doesn't depend on Android APIs?

Post approximate size of finished build, and post number of methods.

Some people hesitate to add a library such as this to their Android project because of concern over increasing the size of their app or hitting the 65K limit of methods allowed by Android.

Posting on the main page of this project site (a) the approximate size and (b) method count would help developers make an informed decision.

Provide sources for documentation ?

Android Studio's javadoc support is great and helpful but since it's a decompiled lib, there's no javadoc available.

Could you provide the sources with the Javadoc included so we could attach it to the decompiled lib ? :)

LocalDate.format returning invalid result

I haven't been able to reproduce this myself, but I am getting reports from the wild that sometimes LocalDate.format() is returning an invalid result.

Here's what happens, as confirmed by the log call in this method and reported via Crashlytics.

  • On entry to this method, month is 2016-08.
  • startOfMonth is correctly set to 2016-08-01.
  • monthString gets set to 0000-00-00 which is wrong.
private Observable<Void> ensureDataForMonthExistsInternal(YearMonth month) {
    final LocalDate startOfMonth = month.atDay(1);
    final String    monthString  = startOfMonth.format(DateTimeFormatter.ISO_LOCAL_DATE);
    Timber.i("Calling ensureDataForMonthExists with month %s, as date %s, formatted %s", month, startOfMonth, monthString);

The only thing I can think of is that this happens as part of the app startup sequence, so maybe AndroidThreeTen isn't fully initialised at this point? It looks as though AndroidThreeTen.init() should be synchronous, though, and this all happens after AndroidThreeTen.init() has returned.

Is there some aspect of AndroidThreeTen which is not fully synchronous?

Here's how I'm calling AndroidThreeTen.init(). It's almost the first thing in my Application.onCreate(), long before the failing sequence of events gets triggered.

@Override
public void onCreate() {
    super.onCreate();
    Fabric.with(this, new Crashlytics.Builder().core(new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build()).build());
    AndroidThreeTen.init(this);

    // other init

    // call failing sequence shown above
}

Reports are coming in from a small percentage of users, which suggests to me it's a timing issue rather than a fundamental problem with the logic.

Make it compatible with Retrofit

I am having issues using this library with Retrofit and GSON.

Since some of the classes, like ZoneId are abstract and GSON can't create them, I am getting exceptions on Retrofit when I try do deserialize my webservice JSON response.

It would be great to have an adapter that could be plugged into Retrofit to provide GSON the ability to deal with this library.

Incorrect FULL_STANDALONE months names

In some languages (e.g. czech, polish, russian, ...) there is difference in month names, whether there are used in context (1. ledna = January 1st) or standalone (leden = January).

The difference is when using "LLLL" in format or
Month.getDisplayName(TextStyle.FULL_STANDALONE, Locale("cs," , "CZ"))

The ThreeTen library uses context name in place of standalone.
SimpleDateTimeTextProvider
Related issue ThreeTen/threetenbp#55

Android formatters format correctly using "LLLL" format, so maybe there would be a way to use correct localization on android.

ThreeTenABP as JAR?

Hello,

I am working w/ multiple gradle modules in my android app. One of them is a pure java module.
As I understand it a Java-Module can not depend on a aar-dependency. Trying to integrate ThreeTenADB into my Java-Module fails w/ build-error:

Error:Module 'xxxxxx' depends on one or more Android Libraries but is a jar

  • Is ThreeTenADB available packaged as JAR?
  • Can I convert a AAR to a JAR?
  • Any other ideas how to mix android- and java-modules witch depends both to a state of the art time implementation?

Thanks!

org.threeten.bp.zone.ZoneRulesException: Unknown time-zone ID: Asia/Hanoi

Version:

1.0.3

Exception:

org.threeten.bp.zone.ZoneRulesException: Unknown time-zone ID: Asia/Hanoi
    at org.threeten.bp.zone.ZoneRulesProvider.getProvider(ZoneRulesProvider.java:178)
    at org.threeten.bp.zone.ZoneRulesProvider.getRules(ZoneRulesProvider.java:133)
    at org.threeten.bp.ZoneRegion.ofId(ZoneRegion.java:143)
    at org.threeten.bp.ZoneId.of(ZoneId.java:357)
    at org.threeten.bp.ZoneId.of(ZoneId.java:285)
    at org.threeten.bp.ZoneId.systemDefault(ZoneId.java:244)
    at<>.(DateAgoFormatter.java:45)
    at <>.(ThreadCardViewCreator.java:533)
    at <>.(ThreadCardViewCreator.java:324)
    at <>.(ThreadCardViewCreator.java:283)
    at <>.(ThreadCardViewCreator.java:71)
    at <>.(Card.java:30)
    at <>.(BaseFeedAdapter.java:91)
    at android.widget.HeaderViewListAdapter.getView(HeaderViewListAdapter.java)
    at android.widget.AbsListView.obtainView(AbsListView.java)
    at android.widget.ListView.makeAndAddView(ListView.java)
    at android.widget.ListView.fillDown(ListView.java)
    at android.widget.ListView.fillFromTop(ListView.java)
    at android.widget.ListView.layoutChildren(ListView.java)
    at android.widget.AbsListView.onLayout(AbsListView.java)
    at android.view.View.layout(View.java)
    at android.view.ViewGroup.layout(ViewGroup.java)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java)
    at android.widget.FrameLayout.onLayout(FrameLayout.java)
    at android.view.View.layout(View.java)
    at android.view.ViewGroup.layout(ViewGroup.java)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java)
    at android.widget.FrameLayout.onLayout(FrameLayout.java)
    at android.view.View.layout(View.java)
    at android.view.ViewGroup.layout(ViewGroup.java)
    at android.support.v4.widget.SwipeRefreshLayout.onLayout(SwipeRefreshLayout.java:598)
    at android.view.View.layout(View.java)
    at android.view.ViewGroup.layout(ViewGroup.java)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java)
    at android.widget.FrameLayout.onLayout(FrameLayout.java)
    at android.view.View.layout(View.java)
    at android.view.ViewGroup.layout(ViewGroup.java)
    at android.support.design.widget.HeaderScrollingViewBehavior.layoutChild(HeaderScrollingViewBehavior.java:122)
    at android.support.design.widget.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:42)
    at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:1192)
    at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:814)
    at android.view.View.layout(View.java)
    at android.view.ViewGroup.layout(ViewGroup.java)
    at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:1191)
    at android.view.View.layout(View.java)
    at android.view.ViewGroup.layout(ViewGroup.java)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java)
    at android.widget.FrameLayout.onLayout(FrameLayout.java)
    at android.view.View.layout(View.java)
    at android.view.ViewGroup.layout(ViewGroup.java)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java)
    at android.widget.FrameLayout.onLayout(FrameLayout.java)
    at android.view.View.layout(View.java)
    at android.view.ViewGroup.layout(ViewGroup.java)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java)
    at android.widget.FrameLayout.onLayout(FrameLayout.java)
    at android.view.View.layout(View.java)
    at android.view.ViewGroup.layout(ViewGroup.java)
    at android.widget.LinearLayout.setChildFrame(LinearLayout.java)
    at android.widget.LinearLayout.layoutVertical(LinearLayout.java)
    at android.widget.LinearLayout.onLayout(LinearLayout.java)
    at android.view.View.layout(View.java)
    at android.view.ViewGroup.layout(ViewGroup.java)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java)
    at android.widget.FrameLayout.onLayout(FrameLayout.java)
    at android.view.View.layout(View.java)
    at android.view.ViewGroup.layout(ViewGroup.java)
    at android.view.ViewRootImpl.performLayout(ViewRootImpl.java)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java)
    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java)
    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java)
    at android.view.Choreographer.doCallbacks(Choreographer.java)
    at android.view.Choreographer.doFrame(Choreographer.java)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java)
    at android.os.Handler.handleCallback(Handler.java)
    at android.os.Handler.dispatchMessage(Handler.java)
    at android.os.Looper.loop(Looper.java)
    at android.app.ActivityThread.main(ActivityThread.java)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)

Question: in which cases is `AndroidThreeTen.init(this)` a "must"?

Is it possible to avoid calling it in some cases?
I've noticed it loads time zones from a file.
It's just that in the Application.onCreate, it takes about 59-70 ms (on Nexus 5x with Android 8.1), and adding this to other libraries that need initialization... it adds up...
I mainly use LocalDate and formatting of it.
Are there any cases that I won't need this call?
Or, which cases would require calling this?

Would having a signed app (with proguard and all) make it a bit faster ? Maybe it will compress the file, so that loading it will be faster?

Cannot compile project

Hi,
I am trying to include this library in my project. But I get a stacktrace every time:

Error:Could not find org.threeten:threetenbp:1.3-SNAPSHOT.
Required by:
:app:unspecified > com.jakewharton.threetenabp:threetenabp:1.0.0-SNAPSHOT

need an update to the TZDB.dat file for Asia/Yangon

Apparently, the Asia/Rangoon TZ has been renamed to Asia/Yangon in the official IANA DB: ftp://ftp.iana.org/tz/tzdb/asia

but ThreeTenABP's TZDB.dat file still references Asia/Rangoon.

Some Android phones still return their locale as Asia/Rangoon and their OS's will never be updated, so ideally, ThreeTenABP would alias the Yangon and Rangoon TZs.

Issue with Robolectric

I just tried to integrate this with Robolectric 3.0 and tests are failing after the first test with this exception:

java.lang.RuntimeException: org.threeten.bp.zone.ZoneRulesException: Unable to register zone as one already registered with that ID: Europe/Sofia, currently loading from provider: TZDB
    at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:244)
    at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:188)
    at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:54)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:152)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:86)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:49)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:64)
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:50)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
    at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
    at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:106)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.messaging.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:360)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.threeten.bp.zone.ZoneRulesException: Unable to register zone as one already registered with that ID: Europe/Sofia, currently loading from provider: TZDB
    at org.threeten.bp.zone.ZoneRulesProvider.registerProvider0(ZoneRulesProvider.java:216)
    at org.threeten.bp.zone.ZoneRulesProvider.registerProvider(ZoneRulesProvider.java:201)
    at com.jakewharton.threetenabp.AndroidThreeTen.init(AndroidThreeTen.java:27)
    at com.example.MyApp(MyApp.java:19)
    at org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:140)
    at org.robolectric.RobolectricTestRunner.setUpApplicationState(RobolectricTestRunner.java:433)
    at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:240)
    ... 35 more

I think the ZoneRulesProvider configuration is statically kept from one test to the other. Any idea if there's a way to fix that at ThreetenABP level or is it a robolectric issue?

Next Release?

Any word on when the next release will be? I'd love to have access to the updated 1.3.2 version for this fix. Thanks!

DateTimeFormatter not properly formatting month and day of week string

I'm trying to format a ZonedDateTime as Tuesday, March 19. But I'm only ending up with Tue, 3 19.

I'm pretty sure I'm following the formatting string guidelines correctly.

DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("EEEE, MMMM d");
String dateString = zonedDateTime.format(dateFormat);

The bizarre part is that when I unit test this code it works fine, but running on an actual Android device truncates day of the week and uses integer for month.

IllegalStateException: TZDB.dat missing from assets

Hi,
I'm writing a unit test with Robolectric 3 (read some data from a sqlite database use Instant for Dates / Times)

The problem is that Robolectric is not able to open the file:

java.lang.IllegalStateException: TZDB.dat missing from assets.
    at com.jakewharton.threetenabp.AndroidThreeTen.init(AndroidThreeTen.java:24)
    at com.droidcon.App.onCreate(App.kt:15)
    at org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:140)
    at org.robolectric.RobolectricTestRunner.setUpApplicationState(RobolectricTestRunner.java:433)
    at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:240)
    at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:188)
    at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:54)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:152)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: java.io.FileNotFoundException: build/intermediates/bundles/debug/assets/org/threeten/bp/TZDB.dat (No such file or directory)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:138)
    at org.robolectric.res.FileFsFile.getInputStream(FileFsFile.java:78)
    at org.robolectric.shadows.ShadowAssetManager.open(ShadowAssetManager.java:168)
    at android.content.res.AssetManager.open(AssetManager.java)
    at com.jakewharton.threetenabp.AndroidThreeTen.init(AndroidThreeTen.java:21)
    at com.droidcon.App.onCreate(App.kt:15)
    at org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:140)
    at org.robolectric.RobolectricTestRunner.setUpApplicationState(RobolectricTestRunner.java:433)
    at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:240)
    at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:188)
    at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:54)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:152)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
    ... 1 more

java.lang.RuntimeException: java.lang.IllegalStateException: TZDB.dat missing from assets.

    at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:244)
    at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:188)
    at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:54)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:152)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: java.lang.IllegalStateException: TZDB.dat missing from assets.
    at com.jakewharton.threetenabp.AndroidThreeTen.init(AndroidThreeTen.java:24)
    at com.droidcon.App.onCreate(App.kt:15)
    at org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:140)
    at org.robolectric.RobolectricTestRunner.setUpApplicationState(RobolectricTestRunner.java:433)
    at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:240)
    ... 18 more
Caused by: java.io.FileNotFoundException: build/intermediates/bundles/debug/assets/org/threeten/bp/TZDB.dat (No such file or directory)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:138)
    at org.robolectric.res.FileFsFile.getInputStream(FileFsFile.java:78)
    at org.robolectric.shadows.ShadowAssetManager.open(ShadowAssetManager.java:168)
    at android.content.res.AssetManager.open(AssetManager.java)
    at com.jakewharton.threetenabp.AndroidThreeTen.init(AndroidThreeTen.java:21)
    at com.droidcon.App.onCreate(App.kt:15)
    at org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:140)
    at org.robolectric.RobolectricTestRunner.setUpApplicationState(RobolectricTestRunner.java:433)
    at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:240)
    at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:188)
    at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:54)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:152)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
    ... 1 more

Basically I wanted to use Robolectric's RuntimeEnvironment.application to get a context to for SqliteOpenHelper.

My App class is just initializing AndroidThreeTen:

class App : Application() {
  override fun onCreate() {
    super.onCreate()
    AndroidThreeTen.init(this)
  }
}

Do you think this is a Robolectric issue? If yes, I will open an issue there

NoClassDefFoundError in android 4.4?

I'm getting a NoClassDefFoundError when initializing the library in Application#onCreate

The stacktrace I'm getting is:

java.lang.NoClassDefFoundError: org.threeten.bp.zone.TzdbZoneRulesProvider
                      at com.jakewharton.threetenabp.AndroidThreeTen.init(AndroidThreeTen.java:28)
                      at com.jakewharton.threetenabp.AndroidThreeTen.init(AndroidThreeTen.java:16)
                      at com.crumbit.crumbitapp.App.onCreate(App.java:99)
                      at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)
                      at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4344)
                      at android.app.ActivityThread.access$1500(ActivityThread.java:135)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
                      at android.os.Handler.dispatchMessage(Handler.java:102)
                      at android.os.Looper.loop(Looper.java:136)
                      at android.app.ActivityThread.main(ActivityThread.java:5017)
                      at java.lang.reflect.Method.invokeNative(Native Method)
                      at java.lang.reflect.Method.invoke(Method.java:515)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
                      at dalvik.system.NativeStart.main(Native Method)

I'm trying to find out why, but meanwhile I have a clue I'm just opening this to see if somebody else has a clue on that, guess that mostly has to do with build process.

Could not find threetenbp-no-tzdb.jar

Hello,

We are using your adaptation of the JSR-310 backport for Android, but since a few days our project could not be build anymore.

We have this error :
Error:Could not find threetenbp-no-tzdb.jar (org.threeten:threetenbp:1.3.3).

Is this dependency still alive ?

Cannot compile

Hi,
I cannot compile 'com.jakewharton.threetenabp:threetenabp:1.0.1'. My test project throws a build error:

Error:Gradle: Execution failed for task ':app:mergeDebugAssets'.
[org/threeten/bp/TZDB.dat] E:\git\WORK\app\build\intermediates\exploded-aar\com.jakewharton.threetenabp\threetenabp\1.0.1\assets\org\threeten\bp\TZDB.dat [org/threeten/bp/TZDB.dat] E:\git\WORK\app\build\intermediates\exploded-aar\com.jakewharton.threetenabp\threetenabp\1.0.1\assets\org\threeten\bp\TZDB.dat: Error: Duplicate resources

Please advise.

wrong year with DateTimeFormatter

When I use the DateTimeFormatter I get a wrong year for the first days of the new year

public class BugTest {

    private final static DateTimeFormatter full = DateTimeFormatter.ofPattern("dd-MMM-YYYY");
    private final static DateTimeFormatter yyyy = DateTimeFormatter.ofPattern("YYYY");

    public static void testYear() {

        print(StringExtensionsKt.convertToDate("2015-12-31T12:00:00+0200"));
        print(StringExtensionsKt.convertToDate("2016-01-01T12:00:00+0200"));
        print(StringExtensionsKt.convertToDate("2016-01-02T12:00:00+0200"));
        print(StringExtensionsKt.convertToDate("2016-01-03T12:00:00+0200"));
        print(StringExtensionsKt.convertToDate("2016-01-04T12:00:00+0200"));
        print(StringExtensionsKt.convertToDate("2016-01-05T12:00:00+0200"));
        print(StringExtensionsKt.convertToDate("2016-01-06T12:00:00+0200"));
        print(StringExtensionsKt.convertToDate("2016-01-07T12:00:00+0200"));
    }

    private static void print(OffsetDateTime dateTime) {

        Timber.i("dateTime: %s full: %s year1: %s year2: %d",
                dateTime, full.format(dateTime), yyyy.format(dateTime), dateTime.getYear());
    }
}

prints the following

dateTime: 2015-12-31T12:00+02:00 full: 31-Dez.-2015 year1: 2015 year2: 2015
dateTime: 2016-01-01T12:00+02:00 full: 01-Jan.-2015 year1: 2015 year2: 2016
dateTime: 2016-01-02T12:00+02:00 full: 02-Jan.-2015 year1: 2015 year2: 2016
dateTime: 2016-01-03T12:00+02:00 full: 03-Jan.-2015 year1: 2015 year2: 2016
dateTime: 2016-01-04T12:00+02:00 full: 04-Jan.-2016 year1: 2016 year2: 2016
dateTime: 2016-01-05T12:00+02:00 full: 05-Jan.-2016 year1: 2016 year2: 2016
dateTime: 2016-01-06T12:00+02:00 full: 06-Jan.-2016 year1: 2016 year2: 2016
dateTime: 2016-01-07T12:00+02:00 full: 07-Jan.-2016 year1: 2016 year2: 2016

From 01-Jan to 03-Jan it has the wrong year. I don't know where it comes from.

private val DATE_FORMATTER = DateTimeFormatter.ISO_DATE
private val DATE_TIME_FORMATTER = DateTimeFormatter.ISO_DATE_TIME
private val DATE_TIME_ZONE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZZ")

fun String.convertToDate(): OffsetDateTime {

    try {
        return OffsetDateTime.parse(this, DATE_TIME_ZONE_FORMATTER)
    } catch (ignored: DateTimeParseException) {
    }

    try {
        return OffsetDateTime.of(LocalDateTime.parse(this, DATE_TIME_FORMATTER), ZoneOffset.ofTotalSeconds(0))
    } catch (ignored: DateTimeParseException) {
    }

    return OffsetDateTime.of(LocalDate.parse(this, DATE_FORMATTER).atTime(0, 0, 0, 0), ZoneOffset.ofTotalSeconds(0))
}

Problem with androidTest in Android Studio 3.0 Canary 4 - assume it's not ThreeTenABP?

I assume this is a problem with Android Studio 3.0 Canary 4 / gradle:3.0.0-alpha4 rather than ThreeTenABP, in which case sorry for wasting your time here, but wanted to ask just in case I'm doing something wrong.

I see 'org.threeten.bp.zone.ZoneRulesException: No time-zone data files registered' when trying to run an androidTest, even though I specify:

// JSR-310 java.time.* backport
 implementation "com.jakewharton.threetenabp:threetenabp:1.0.5"
 // For testing, require version containing assets in Android-inefficient manner
 // see: https://github.com/JakeWharton/ThreeTenABP/issues/14
 androidTestImplementation("org.threeten:threetenbp:1.3.3") {
     exclude group: 'com.jakewharton.threetenabp', module: 'threetenabp'
 }

https://github.com/alteredworlds/androidtestcompileexclude

org.threeten.bp.zone.ZoneRulesException: Unable to load TZDB time-zone rules

Version:

1.0.3

Exception:

java.lang.RuntimeException: Unable to create application App: org.threeten.bp.zone.ZoneRulesException: Unable to load TZDB time-zone rules
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4809)
    at android.app.ActivityThread.access$1600(ActivityThread.java:154)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1452)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:234)
    at android.app.ActivityThread.main(ActivityThread.java:5526)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: org.threeten.bp.zone.ZoneRulesException: Unable to load TZDB time-zone rules
    at org.threeten.bp.zone.TzdbZoneRulesProvider.<init>(TzdbZoneRulesProvider.java:124)
    at com.jakewharton.threetenabp.AndroidThreeTen.init(AndroidThreeTen.java:22)
    at <>.onCreate(ApplicationState.java:162)
    at
Caused by: java.io.EOFException
    at java.io.DataInputStream.readByte(DataInputStream.java:77)
    at org.threeten.bp.zone.TzdbZoneRulesProvider.loadData(TzdbZoneRulesProvider.java:233)
    at org.threeten.bp.zone.TzdbZoneRulesProvider.load(TzdbZoneRulesProvider.java:212)
    at org.threeten.bp.zone.TzdbZoneRulesProvider.<init>(TzdbZoneRulesProvider.java:122)
    ... 14 more

ThreeTen is ignoring Android 24/12 hour display settings

When trying to print ZoneDateTime time using DateTimeFormatter, the user system settings regarding 24/12 hour display is ignored

The issue is if you use:
DateTimeFormatter timeFormat = DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT);

The time format will only consider the Locale and not the user settings, example:
DE Locale will display a 24Hours format: 23:30
EN Locale will display a 12Hours format: 11:30 PM
Regardless of the user system settings.

android.text.DateFormat.getTimeFormat(Context context) will take the system settings in consideration but only accepts Date objects, the conversion isn't straight forward and might lead to mistakes.

Question: how to properly convert between LocalDateTime (or LocalDate/LocalTime with what's available) and Date/Calendar?

Official way is to do this could be (according to this link) :

LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
LocalDateTime.ofInstant(calendar.toInstant(), ZoneId.systemDefault());

But since this is a backport, which would work on old Android versions too, I can't just call toInstant, because it's not available yet.

How should I convert between them?
Also, what's the best way to convert back to Date/Calendar ?

Getting pure-java modules with ThreeTenBP to play nice with ThreeTenABP?

Disclaimer: this is probably a gradle config issue rather than an issue with this library per-se. But hopefully this issue is relevant to android developers wanting to use JSR 310 in multi-module projects.

I have a pure java (non-android) gradle module called common with some utility functions for building ZonedDateTime objects. It depends on the standard jvm backport library (org.threeten:threetenbp).

What I'd like is to have the android app module depend on the common module to make use of these platform-independent utility functions, but depend on threetenABP instead for performance. Should this be possible? Attempting to do it naiively gives this build error:

Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDevelopDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK org/threeten/bp/format/ChronologyText.properties
  	File1: /Users/matthewcl/.gradle/caches/modules-2/files-2.1/org.threeten/threetenbp/1.3.1/5769e9c27cd5ba74cd3a73785dde0bbb5a2d3c0d/threetenbp-1.3.1.jar
  	File2: /Users/matthewcl/.gradle/caches/modules-2/files-2.1/org.threeten/threetenbp/1.3.1/fecd59cfa6acebf3d0f2f41f55a1cc3e24e59726/threetenbp-1.3.1-no-tzdb.jar

From what I understand, the same public classes and interfaces are in use in both modules (e.g. ZonedDateTime). It seems like something like gradle's provided keyword to have compilation succeed and yet use ABP at runtime would work, but I haven't had much success with it.

Any thoughts?

Question: Where's the code exactly?

It is said this library is better than ThreeTenBP repo, here .

So I was curious and looked at the repo's files, but I don't see a lot at all, especially not of LocalDate, which I somehow use by using this repo.

How could it be?

Is it somehow using the threetenbp library, yet with some changes applied?

If so, is it frequently updated like it? Maybe even auto-updated ? I ask this because I notice that the threetenbp library seems updated more recently (has some files updated 6 months ago), yet here it's not (newest files updated 11 months ago) .

InputStream is leaked in AndroidThreeTen.init()

try {
    InputStream is = application.getAssets().open("org/threeten/bp/TZDB.dat");
    provider = new TzdbZoneRulesProvider(is);
} catch (IOException e) {
    throw new IllegalStateException("TZDB.dat missing from assets.", e);
}

is is not closed, either here or inside TzdbZoneRulesProvider as far as I could see.

Cannot Run Project on Android Phone Even After Compiling Due to "unable to merge dex" Error

I am currently using the Android Studio 3.0 and I have faced this problem of compiling this project with ApexNLP library and I am facing this error. I tried the library in the previous version of the android studio but it still failed. I need the ApexNLP library for the project. So please help me out.

ApexNLP Project Link :
https://github.com/6thsolution/ApexNLP

Error:
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.

com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

Cannot use Joda's methods

Hi,
I used to be able to use Jodatime's DateTime and ISODateTimeFormat. Now, I cannot with ThreeTenABP. Is there an equivalent api for these calls?

Thanks,
Igor

Android Studio preview?

Is there a way to make ThreeTenABP work in Android Studio's Preview tab? Initialising the library when in edit mode still raises the errors below in the preview tab.

I've tried @tymm's solution for #24 to no avail. Any suggestions?

Error after building the project:

java.io.FileNotFoundException: Asset file: org/threeten/bp/TZDB.dat
    at android.content.res.AssetManager.open(AssetManager.java:354)
    at android.content.res.AssetManager.open(AssetManager.java:321)
    at com.jakewharton.threetenabp.AndroidThreeTen.init(AndroidThreeTen.java:27)
    at some.package.name.view.SomeCustomView.<init>(SomeCustomView.kt:61)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:465)
    at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:172)
    at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:105)
    at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:186)
    at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:334)
    at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:345)
    at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:245)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:858)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
    at android.view.LayoutInflater_Delegate.parseInclude(LayoutInflater_Delegate.java:197)
    at android.view.LayoutInflater.parseInclude(LayoutInflater.java:902)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:854)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:861)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:324)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:429)
    at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:389)
    at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:548)
    at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:533)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:966)
    at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:533)
    at com.android.tools.idea.rendering.RenderTask.lambda$inflate$53(RenderTask.java:659)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

Error after refreshing the layout:

org.threeten.bp.zone.ZoneRulesException: No time-zone data files registered
    at org.threeten.bp.zone.ZoneRulesProvider.getProvider(ZoneRulesProvider.java:176)
    at org.threeten.bp.zone.ZoneRulesProvider.getRules(ZoneRulesProvider.java:133)
    at org.threeten.bp.ZoneRegion.ofId(ZoneRegion.java:143)
    at org.threeten.bp.ZoneId.of(ZoneId.java:357)
    at org.threeten.bp.ZoneId.of(ZoneId.java:285)
    at org.threeten.bp.ZoneId.systemDefault(ZoneId.java:244)
    at org.threeten.bp.Clock.systemDefaultZone(Clock.java:137)
    at org.threeten.bp.OffsetDateTime.now(OffsetDateTime.java:175)
    at some.package.name.view.SomeCustomView.updateItems(SomeCustomView.kt:77)
    at some.package.name.view.SomeCustomView.<init>(SomeCustomView.kt:72)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:465)
    at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:172)
    at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:105)
    at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:186)
    at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:334)
    at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:345)
    at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:245)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:858)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
    at android.view.LayoutInflater_Delegate.parseInclude(LayoutInflater_Delegate.java:197)
    at android.view.LayoutInflater.parseInclude(LayoutInflater.java:902)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:854)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:861)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:324)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:429)
    at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:389)
    at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:548)
    at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:533)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:966)
    at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:533)
    at com.android.tools.idea.rendering.RenderTask.lambda$inflate$53(RenderTask.java:659)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

Initialisation used in the custom view:

if(isInEditMode)
    AndroidThreeTen.init(context)

No timezone data files registered

Why would I be getting this? Are the time zone rules not part of the package?
This is the error I get:
System.err: org.threeten.bp.zone.ZoneRulesException: No time-zone data files registered
Here is my code:

DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss VV", Locale.ENGLISH)
                .withZone(ZoneId.of(cruiseShipEntity.getDateBuilt().getTimeZone()));
ZonedDateTime dateBuilt = ZonedDateTime.parse("2012-06-03 00:00:00 America/New_York", dateTimeFormatter);

Why is `minSdkVersion` set to 15? Could it be lower?

Hi,

I was just wondering: why is minSdkVersion set to 15? Is it possible to set it lower?
I'm working on a library which depends on ThreeTenABP and noticed I had to bump up the version just to support it.

Thanks!

Abel
Cooking Fox

TemporalAccessor API different from Java8

For those that are trying to derive their own class from TemporalAccessor might notice that in Java8 (see the source code here) the get, query and range methods are default methods means one does not have to override them. However, on Android I have to override those methods.

I know that the interface is marked as a framework-level interface, however reading the javadoc makes me believe that one does not necessarily want to avoid users creating subtypes but rather make them use specific types instead of generic ones. Please correct me if I'm wrong or point me to a better solution if there is one. The reason why I'm trying to inherit from TemporalAccessor is because DateTimeFormatter.format takes a TemporalAccessor as an argument.

MinSDK higher than needed

Is there a reason I do not see to have minSDK on 15? It seems to also compile with 5:

diff --git a/build.gradle b/build.gradle
index 7f365e4..87c8e03 100644
--- a/build.gradle
+++ b/build.gradle
@@ -14,7 +14,7 @@ allprojects {
}

ext {

  • minSdkVersion = 15
  • minSdkVersion = 5
    compileSdkVersion = 22
    buildToolsVersion = '22.0.1'

Question about performance/getResourceAsStream()

As you explained the main motivation to wrap Threeten-backport for Android is to avoid the method ClassLoader.getResourceAsStream(). I have two questions:

a) Have you observed any performance gains or done some micro benchmark tests?

b) Are you aware of following Google-issues and commits which might make your approach obsolete in the future? I would be graceful for any opinions and estimations which can help to widen our understanding for the resource-loading-issue on Android.

Use Android TimeZone instead of Database

Hey,

i wonder, whether there is a reason to use the Timezones Database instead of the Android Timezones directly?
Of course, it might be sometimes good to have a newer database version, but most of the time it makes problem, when they are not in sync... Apps using Joda will show another "Current Local Time" than the OS.

As solution i had a TimeZone Provider for JodaTime: dlew/joda-time-android#165
it should be possible to adapt it similiar to this library

i am using it for a while, and did not have any issues till now...

it might be a good idea, to make this default (or at least configurable)

or is there something i miss, why thats not a good idea?

Documentation missing?

I've installed this package successfully in my Android project. The problem is that I get no documentation when I use the quick reference (F1) on Android Studio.

From a quick google search, I've found the original org.threeten.bp documentation. Is it possible to have that accessible from Android Studio?

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.