Giter Club home page Giter Club logo

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

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

joda-time-android's People

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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

joda-time-android's Issues

Issue with latest gradle plugin 1.3.0-beta1

So.. I wanted to try out the data-binding library and needed to use the new gradle plugin. Apparently the new plugin enforces that any resource starts with a lowercase letter and can not start with a "_".

All the resource names starts with "__" throwing a compile error:

Error:Error: File-based resource names must start with a lowercase letter

Updating Joda Time Version

Is there a canonical way to update the actual joda-time library? I need some bug fixes that are in Joda-time 2.6 but I'm not sure how to upgrade it.

DateTimeFormat default locale doesn't respect 24 hour time display

Using the default locale with DateTimeFormat.shortTime() doesn't appear to respect the phone's setting to use 24 hour time instead of AM/PM. I can make custom formatters based on DateFormat.is24HourFormat, but that's a pain in the neck.

This is potentially an easy fix, so I'll look into it and send you a pull request if I find a solution.

Please update tzdata to 2014g

I know its possible to do it manually, but it would be VERY convenient to just add fresh gradle dependency without modifiyng anything.

Thanks in advance!

Cannot use alongside com.fasterxml.jackson.datatype:jackson-datatype-joda:2.5.0

Hi

It is highly likely I am being very stupid, but when including both net.danlew:android.joda:2.7.0 (To get your library) and com.fasterxml.jackson.datatype:jackson-datatype-joda:2.5.0 (To get jackson to joda serializaion), Dex balks at the ":app:dexDebug" stage of gradle compilation, and refuses to work, reporting

com.android.dex.DexException: Multiple dex files define Lorg/joda/time/Chronology;
    at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
    at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
    at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
    at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
    at com.android.dx.command.dexer.Main.run(Main.java:246)
    at com.android.dx.command.dexer.Main.main(Main.java:215)
    at com.android.dx.command.Main.main(Main.java:106)

Do you think this is me doing something stupid, or something that can be fixed in the library?

Thanks

mergeResources error with Android Gradle plugin 1.3

After upgrading to plugin 1.3.0-beta1, I'm receiving an error:

Error:Execution failed for task ':app:mergeDebugResources'.
> /<path to my project>/app/build/intermediates/exploded-aar/net.danlew/android.joda/2.7.2/res/raw/__tzdata_africa_abidjan: Error: File-based resource names must start with a lowercase letter

Need to check if this will be fixed on next releases of the plugin or the library needs to be fixed.

Can't find referenced class org.joda.time.tz.ZoneInfoCompiler

Hi! I've added joda time to my project as a dependency:

dependencies {
compile 'net.danlew:android.joda:2.7.0'
}

But when generating a signed APK, Android Studio shows this warning: "Warning:org.joda.time.tz.DateTimeZoneBuilder$PrecalculatedZone: can't find referenced class org.joda.time.tz.ZoneInfoCompiler"

Should I ignore it adding a "-dontwarn" in proguard?

Android Resource not found issue.

Hi,
I have an issue in my android project.when i use your this jar for some timezone.please help me what is this issue.

E/AndroidRuntime(3028): FATAL EXCEPTION: AsyncTask #1
10-14 12:16:28.232: E/AndroidRuntime(3028): java.io.IOException: Resource not found: "org/joda/time/tz/data/ZoneInfoMap" ClassLoader: dalvik.system.DexClassLoader[DexPathList[[zip file "/data/data/com.xxx.xxx/files/dlibs/libs-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.xxx.xxx-1, /vendor/lib, /system/lib]]]
10-14 12:16:28.232: E/AndroidRuntime(3028): at org.joda.time.tz.ZoneInfoProvider.openResource(ZoneInfoProvider.java:211)
10-14 12:16:28.232: E/AndroidRuntime(3028): at org.joda.time.tz.ZoneInfoProvider.(ZoneInfoProvider.java:123)
10-14 12:16:28.232: E/AndroidRuntime(3028): at org.joda.time.tz.ZoneInfoProvider.(ZoneInfoProvider.java:82)
10-14 12:16:28.232: E/AndroidRuntime(3028): at org.joda.time.DateTimeZone.getDefaultProvider(DateTimeZone.java:462)
10-14 12:16:28.232: E/AndroidRuntime(3028): at org.joda.time.DateTimeZone.setProvider0(DateTimeZone.java:416)
10-14 12:16:28.232: E/AndroidRuntime(3028): at org.joda.time.DateTimeZone.(DateTimeZone.java:115)
10-14 12:16:28.232: E/AndroidRuntime(3028): at com.amazonaws.util.DateUtils.(Unknown Source)
10-14 12:16:28.232: E/AndroidRuntime(3028): at com.amazonaws.services.s3.internal.ServiceUtils.(Unknown Source)
10-14 12:16:28.232: E/AndroidRuntime(3028): at com.amazonaws.services.s3.internal.S3Signer.sign(Unknown Source)
10-14 12:16:28.232: E/AndroidRuntime(3028): at com.amazonaws.http.AmazonHttpClient.executeHelper(Unknown Source)
10-14 12:16:28.232: E/AndroidRuntime(3028): at com.amazonaws.http.AmazonHttpClient.execute(Unknown Source)
10-14 12:16:28.232: E/AndroidRuntime(3028): at com.amazonaws.services.s3.AmazonS3Client.invoke(Unknown Source)
10-14 12:16:28.232: E/AndroidRuntime(3028): at com.amazonaws.services.s3.AmazonS3Client.createBucket(Unknown Source)
10-14 12:16:28.232: E/AndroidRuntime(3028): at com.amazonaws.services.s3.AmazonS3Client.createBucket(Unknown Source)
10-14 12:16:28.232: E/AndroidRuntime(3028): at com.xxx.xxx.presentations.data.AmazonFileUploader.uploadPdf(AmazonFileUploader.java:37)
10-14 12:16:28.232: E/AndroidRuntime(3028): at com.xxx.xxx.xxx.xxx.dialogs.PdfViewerDialog$savePresentationTask.doInBackground(PdfViewerDialog.java:143)
10-14 12:16:28.232: E/AndroidRuntime(3028): at com.xxx.xxx.presentations.fragments.dialogs.PdfViewerDialog$savePresentationTask.doInBackground(PdfViewerDialog.java:129)
10-14 12:16:28.232: E/AndroidRuntime(3028): at android.os.AsyncTask$2.call(AsyncTask.java:287)
10-14 12:16:28.232: E/AndroidRuntime(3028): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
10-14 12:16:28.232: E/AndroidRuntime(3028): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
10-14 12:16:28.232: E/AndroidRuntime(3028): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
10-14 12:16:28.232: E/AndroidRuntime(3028): at java.lang.Thread.run(Thread.java:841)

Lint error

I get a lint error - InvalidPackage: Package not included in Android when I run lint on an app using your awesome library.

Assuming this is not a real error, would it make sense to add a @SuppressLint annotation where applicable?

The full Lint error is:

Invalid package reference in library; not included in Android: javax.xml.bind. Referenced from org.joda.convert.JDKStringConverter.9.
Priority: 6 / 10
Category: Correctness
Severity: Error
Explanation: Finds API accesses to APIs that are not supported in Android.
This check scans through libraries looking for calls to APIs that are not included in Android.

When you create Android projects, the classpath is set up such that you can only access classes in the API packages that are included in Android. However, if you add other projects to your libs/ folder, there is no guarantee that those .jar files were built with an Android specific classpath, and in particular, they could be accessing unsupported APIs such as java.applet.

JodaTimeAndroid is null after screen rotation

Declared JodaTimeAndroid.init(this); in public class BLABLAApplication extends Application {@OverRide
public void onCreate() {
super.onCreate();
NetworkHelper.getInstance().initialize(this);
BusHelper.post(new InitializeAction());
JodaTimeAndroid.init(this);
}}

but after device rotation the objects are null, is JodaTimeAndroid a Singleton?!

Error when updating timezone database on windows

The command 'gradlew.bat updateTzDatac' failed with an error stating the main class for org.joda.time.tz.ZoneInfoCompiler could not be found.

Changing the 24th line in 'build.gradle' file from:
classpath = files("build/bundles/debug/classes.jar")
to:
classpath = files("build/intermediates/bundles/debug/classes.jar")

seems to resolve the issue.

~Josiah

Time Zone crash

I am getting this crash with version 2.7.1

java.lang.IllegalArgumentException: The datetime zone id 'Africa/Abidjan' is not recognised

What should I do? It is really confusing. It is working normally with the original joda-time library. Should I checkout this repo and get timezones myself?

as jar ?

Hi, thank you for this android oriented version of joda time!

I was wondering if a package version as not aar to be used without gradle nor maven is possible?

It's because I'm doing Android app with Scala and it is a mess to use gradle. Pure IntelliJ is easier to configure.

Thanks

PeriodFormat string resources are in ISO 8859-1 encoding instead of UTF-8

Description

The resource bundle strings for PeriodFormat (and possibly others) are using ISO Latin-1 encoding instead of UTF-8.

For example this file is not UTF-8 encoded (actual encoding ISO 8859-1):

https://github.com/dlew/joda-time-android/blob/master/library/src/org/joda/time/format/messages_es.properties.

NOTE: github shows it without problems because it detects it correctly as ISO-8859-1.

These files have incorrect encoding:

messages_es.properties
messages_fr.properties
messages_da.properties
messages_pt.properties

Actual result

Strings render in android apps with broken accented characters.

Expected result

Accented characters are displayed correctly.

Suggested solution

Re-encode the .properties to UTF-8 or to Unicode escapes.

Example using iconv:

iconv -f ISO-8859-1 -t UTF-8 messages_es.properties > messages_es_UTF8.properties

Timezone not always being converted properly

I have encounter a new issue related to timezones. In at least one of them, the conversion is not working properly. Try this DateTime object:

new DateTime(DateTimeZone.forID("Asia/Dhaka"))

For me it returns a DateTime with GMT+7 timezone when it should have been +6 (as per the timezone data file). I'm trying to find out where the problem is and will let you if I find out.

Thanks.
Edit: If I don't use your library but just the latest DateTime library instead, the timezone gets parsed correctly.

new DateTime() uses UTC instead of current system time zone

I am seeing the same issue as #20, when I call DateTime.now().getZone() it returns UTC even though the actual time is GMT; DateTimeZone.getDefault() returns UTC, and TimeZone.getDefault() returns GMT. I have performed some debugging within the library as requested in #20 and getZone() within the ResourceZoneInfoProvider is called with a Zone of UTC.

In answer to the questions you asked the guy in the original issue:

  • What version of Android are you using?
    • Lollipop 5.0.1
  • What device are you using?
    • Issue occurs on both the Emulator and on my HTC One M8
  • What timezone is your phone set to (exactly)?
    • Europe/London / GMT
  • Any sample code?
    • I am able to recreate the error in the Samples included in the library.

Is there any other steps I can perform to help get to the root of the problem?

DateTimeFormatter.fullDateTime() not entirely compatible with android

The default formats provided through JodaTime are not entirely compatible with Android.

A simple demonstration is to use the DateTimeFormatter.fullDateTime() method in your code, and have the phone set to use Suomi as language, which will fail because the android version of SimpleDateFormat includes 'c' for "stand-alone day of week" which is not supported by JodaTime.

Unit test error

I followed the directions on this page: http://tools.android.com/tech-docs/unit-testing-support

I created a test class, compiled it but I ran into this:
Resource not found: "org/joda/time/tz/data/ZoneInfoMap" ClassLoader: sun.misc.Launcher$AppClassLoader@5bdf59bd

I copied everything to a simple Java project (switched to IntelliJ) and my unit tests ran just fine.

Gradle info
compile 'net.danlew:android.joda:2.7.1'
testCompile 'junit:junit:4.12'

Froyo Support?

Is there any particular reason why joda-time-android does not support API 8?

org.joda.time.IllegalFieldValueException: Value 0 for monthOfYear must be in the range [1,12]

10-02 17:52:25.617: E/AndroidRuntime(24239): org.joda.time.IllegalFieldValueException: Value 0 for monthOfYear must be in the range [1,12]
10-02 17:52:25.617: E/AndroidRuntime(24239): at org.joda.time.field.FieldUtils.verifyValueBounds(FieldUtils.java:252)
10-02 17:52:25.617: E/AndroidRuntime(24239): at org.joda.time.chrono.BasicChronology.getDateMidnightMillis(BasicChronology.java:612)
10-02 17:52:25.617: E/AndroidRuntime(24239): at org.joda.time.chrono.BasicChronology.getDateTimeMillis(BasicChronology.java:159)
10-02 17:52:25.617: E/AndroidRuntime(24239): at org.joda.time.chrono.GregorianChronology.getDateTimeMillis(GregorianChronology.java:1)
10-02 17:52:25.617: E/AndroidRuntime(24239): at org.joda.time.chrono.AssembledChronology.getDateTimeMillis(AssembledChronology.java:120)
10-02 17:52:25.617: E/AndroidRuntime(24239): at org.joda.time.LocalDate.(LocalDate.java:457)
10-02 17:52:25.617: E/AndroidRuntime(24239): at org.joda.time.LocalDate.(LocalDate.java:436)

lower case?

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

/path _to_app/Source/app/build/intermediates/exploded-aar/net.danlew/android.joda/2.7.2/res/raw/__tzdata_africa_abidjan: Error: File-based resource names must start with a lowercase letter

can't find referenced class org.joda.time.tz.ZoneInfoCompiler

I can't generate a apk with proguard active, I always get the following warning:

Warning:org.joda.time.tz.DateTimeZoneBuilder$PrecalculatedZone: can't find referenced class org.joda.time.tz.ZoneInfoCompiler

I know I could add -dontwarn org.joda.time.tz.**, but then the app crashes when I call JodaTimeAndroid.init(this);

@OverRide
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.activity_main);
JodaTimeAndroid.init(this);
}

I'm using Android Studio

the exception I get when I use -dontwarn:

02-22 12:57:16.237 6971-6971/? E/JodaTimeAndroid﹕ Failed to retrieve identifier: type=class net.danlew.android.joda.R$raw name=__tzdata_zoneinfomap
java.lang.NoSuchFieldException: __tzdata_zoneinfomap
at java.lang.Class.getField(Class.java:1048)
at net.danlew.android.joda.ResUtils.getIdentifier(ResUtils.java:105)
at net.danlew.android.joda.ResourceZoneInfoProvider.openResource(ResourceZoneInfoProvider.java:114)
at net.danlew.android.joda.ResourceZoneInfoProvider.(ResourceZoneInfoProvider.java:39)
at net.danlew.android.joda.JodaTimeAndroid.init(JodaTimeAndroid.java:39)
at com.newApp.MainActivity.onCreate(MainActivity.java:158)
at android.app.Activity.performCreate(Activity.java:5933)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
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:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
02-22 12:57:16.239 6971-6971/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.newApp, PID: 6971
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.newApp/com.newApp.MainActivity}: java.lang.RuntimeException: Could not read ZoneInfoMap
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
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:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.RuntimeException: Could not read ZoneInfoMap
at net.danlew.android.joda.JodaTimeAndroid.init(JodaTimeAndroid.java:42)
at com.newApp.MainActivity.onCreate(MainActivity.java:158)
at android.app.Activity.performCreate(Activity.java:5933)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
            at android.app.ActivityThread.access$800(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5221)
            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:899)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

Possible race condition between joda-time-android, Ion, and GSON

I recently switched from joda-time to use joda-time-android and ran into a strange race condition that I'd like to understand. This issue manifests, I think, due to my use of Ion (https://github.com/koush/ion), set up to use a custom GSON (https://code.google.com/p/google-gson/) for serialization and deserialization. It doesn't manifest when I use vanilla joda-time, which unfortunately uses more memory and tends to block the main thread for longer as it bootstraps.

In my Application subclass, I set up JodaTimeAndroid, GSON, and configure Ion to use the custom Gson instance to serialize/deserialize DateTime:

@Override
public void onCreate() {
    ...

    super.onCreate();

    JodaTimeAndroid.init(this);

    ...

    Gson gson = new GsonBuilder()
            .setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
            .setLongSerializationPolicy(LongSerializationPolicy.DEFAULT)
            .registerTypeAdapter(DateTime.class, new DateTimeDeserializer())
            .registerTypeAdapter(DateTime.class, new DateTimeSerializer())
            .create();

    Ion.getDefault(this).configure().setGson(gson);
}

...

private static class DateTimeSerializer implements JsonSerializer<DateTime> {
    public JsonElement serialize(DateTime src, Type typeOfSrc, JsonSerializationContext context) {
        return new JsonPrimitive(src.toString());
    }
}

private static class DateTimeDeserializer implements JsonDeserializer<DateTime> {
    public DateTime deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
            throws JsonParseException {
        return new DateTime(json.getAsJsonPrimitive().getAsString());
    }
}

Some short time later, I make a network call with Ion in a Service, serializing into a POJO model that has a DateTime field. It also happens to be wrapped in an RxJava Observable run on the IO scheduler:

                                        Observable.from(
                                                Ion.with(this)
                                                        .load(uri)
                                                        .as(ChannelTimelineMap.class),
                                                Schedulers.io()))

One out of every few restarts of the Application, GSON throws an error, saying it can't parse a string timetamp into my DateTime object. I know there's a lot of interplay between libraries here, but also thought you'd have insight since you work with a lot of them already and, y'know, wrote this library ;)

Also I'm a huge fan, thanks for all the fantastic work and writing you've done!

Sources/Javadoc missing

Hi, I noticed that sources and javadoc are missing, it is because joda-time is not exporting them to Maven central?

Possibly use joda-time as a dependency instead of including it in this project

DateTimeZone no longer uses a static setter for the default provider, thus it is now avoidable to

That said - using joda-time as a dependency introduces one big problem: it'll increase the size of the lib by half a meg since we'll be double-including the TZ data.

Either we should figure out a way to disinclude the JAR TZ data, or we should convince joda-time to provide a version that doesn't include it by default.

Setup receiver to listen to timezone changes

Right now, joda-time caches the default DateTimeZone the first time you request it. It's possible the user may change their timezone (either automatically or manually). joda-time-android should listen to "android.intent.action.TIMEZONE_CHANGED" and update the default accordingly.

Usage in unit testing

When unit testing the Android app (junit.framework.TestCase or Junit 4 tests from a pure submodule) joda-time-android cannot be used as it requires a context as part of the JodaTimeAndroid.initialization.

The alternative is to obviously just use joda-time for submodules and converting TestCases to AndroidTestCases (in the process getting hold of a context for initialization).

In you experience have you had to deal with a similar case and if so did you choose an alternative nicer approach for unit testing? Conceptually it would be nice to have the exact same JodaTime library used for both testing and production, but is this just a limitation that can't be overcome?

Cheers

DateTimeZone.getDefault() sometimes return right value, sometimes return utc

This is exactly what happens to me. I have your last version installed.
I tried using "JodaTimeAndroid.init(this);" in the onCreate of the first activity on my app. As it sometimes failed, then I put it in the onCreate of the activity where I use Joda mostly, and as it still fails, now I put it in the onResume of the activity i use Joda mostly..

But it's still not working..

Any suggestion??

My current timezone is "Europe/Dublin".

BTW: I don't use setDefaultTimeZone at all.

EDIT: it's not a problem that there is no timezones available because after retrieve my current timezone, I show my available timezones and I have 583..

Version 2.8.0 not available in Maven Central

Version 2.8.0, listed as the current version in the README will not download and compile in from mavencentral.

I notice that it has only just gone live, so perhaps it's just a caching/timing issue - in which case ignore this - but I thought I'd bring it up just in case something went wrong with the push.

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.