joda-time
joda-time copied to clipboard
Create option for joda-time to use the time zone information from the JDK
In an enterprise environment where there are many isolated applications that utilize joda-time, updating the version of joda-time in each application can be time-consuming and could be considered bad practice to change a deployed application. With the availability of the tzupdater utility [1] for Sun/Oracle JREs, updating the time zone recognized by the JRE has become a fairly trivial, one step process (per JRE). It would be beneficial to have an option for joda-time to use the time zone information provided by the JRE.
With the understanding that joda-time was written prior to the availability of the tzupdater and the fact that the tzupdater may be an enterprise-level solution, I would envision this enhancement as an optional feature that can be turned on (or off) as needed.
[1] - http://www.oracle.com/technetwork/java/javase/tzupdater-readme-136440.html
While this would be desirable, when I looked previously the JDK did not provide enough information to satisfy the Joda-Time API. I doubt this has changed.
It would certainly be interesting to see a pull request or separate project try to achieve this. Its not something I'm going to work on any time soon.
Another option may be to have a system property available that lets the user specify an alternative location for the TZdata file.
This way you could run your application with -Djoda.tzfile=/some/path/to/my/tzfile
If the file doesn't exist or is otherwise invalid, I'd just print a message to a logger to sys.err and fall back to the compiled jar version.
I could go with joda watching this file for changes or not. A manual restart of the application on TZ updates isn't too bad for some applications, but I could see other enterprise apps not handling it as nicely
We've recently run into this same situation with wanting to update our joda-time rules without having to reassemble across many applications. We arrived at the same idea @johnjaylward mentioned of allowing a property to be defined to point where joda-time would check an alternative location for the files.
We'd be interested in submitting a patch for this if you're interested in this idea, I didn't know if you would want us to create a new JIRA for this request since it's slightly out of scope with reading time-zone information from the JDK.
Is it possible to implement org.joda.time.tz.Provider
using the new java.time.zone.ZoneRulesProvider
? Has anyone done this?
I would have thought it would be possible. I've not looked myself.