Joda-Time provides a well-documented, well-tested and easy to use Java library for date and time handling including the ISO8601 standard. It completely replaces the JDK Date and Calendar classes, while still providing good integration. It is open-source software under the ASF2 license.
Version 1.3 has just been released. This release fixes a number of minor bugs in v1.2 and adds two key new features:
These represent a date, time or datetime without a time zone. As such LocalDate is a direct replacement for YearMonthDay, whilst LocalTime replaces TimeOfDay. Neither of the replaced classes has been deprecated yet however, due to their widespread adoption. The new classese fix some strange semantics with the old classes.
- withXxx() methods
These methods, such as withDayOfMonth(int) or withHourOfMinute(int) have been added to all immutable datetime classes. They perform a similar function to set methods, but return a new instance of the datetime object (due to immutability). These are convenience methods for functionality previously available via the property.
For example, setting the year previously was done as follows:
DateTime year2000 = dt.year().setCopy(2000);
Now the direct 'with' method can be used:
DateTime year2000 = dt.withYear(2000);
As more APIs get developed with immutable classes, we in Joda-Time hope that the concept of 'set' methods for mutable objects and 'with' methods for immutable objects will become a more widely accepted idea. One could easily imagine the large web frameworks using a 'with' convention to manage immutable objects just like mutable JavaBeans are handled now.
As always, feedback is welcomed.