Allen Rohner <aroh...@gmail.com> writes:

> http://www.ociweb.com/jnb/jnbJul2008.html  "As mentioned, one of the
> problems with the JDK API is difficulty in calculating the number of
> days between two different dates. To learn a bit about how to use Joda
> Time, let's see how one can solve that problem a few different ways
> using Joda Time. The example finds the number of days from January 1,
> 2008 to July 1, 2008 ... While this might seem a trivial problem, it
> actually is not simple using just the JDK. The typical approach used
> with the JDK is to compare the timestamps for the midnights of January
> 1 and July 1 and divide the result by the number of milliseconds in a
> day. While this works in some cases, my computer would give 181.958333
> using that approach instead of 182 for the given example. Why? Because
> my computer is set to use Daylight Saving Time in the northern
> hemisphere, and one hour was skipped in the first half of the year."

> http://jcp.org/en/jsr/detail?id=310  This is the JSR for the
> replacement of the java date/time libraries. The replacement is being
> written by the author of Joda time, largely based on his experience in
> Joda time. Section 2.5 of the JSR lists many current problems with the
> java std lib time representation.

Very interesting; I will take a closer look. I'm not convinced the
problems can't be worked around once we are made aware of them, but it
definitely merits further investigation.

What's the status of this JSR? Is it possible the JDK 7 will include
more palatable date processing capabilities? I think it would be a shame
if external libraries were required to get sane date processing in
Clojure, but if the JDK 7 has potential to fix it, that's encouraging.

Most of the problems mentioned seem to be related to timezones. It seems
the worst case scenario is simply to have Chrono support no
timezone-aware operations out of the box on JDKs 5 and 6, but be able to
offer greater capabilities if either the JDK 7 or Joda time is
installed. I agree that having a more limited library is better than
having one that claims to have greater capabilities, but has bugs.

> Additionally, the Joda library heavily emphasizes immutable objects.

Everything in Chrono is immutable as well, provided you stick to the
functions in Chrono. You can still poke under the covers and get at the
underlying calendar objects, but there's no danger that someone would do
that without knowing what they were getting into.

It would be pretty easy to always return a copy of the underlying
calendar as well if providing (undocumented) access to the mutable
object turns out to be an issue.

-Phil

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to