Joda-Time provides a quality replacement for the Java date and time classes. The design allows for multiple calendar systems, while still providing a simple API. The 'default' calendar is the ISO8601 standard which is used by XML. The Gregorian, Julian, Buddhist, Coptic and Ethiopic systems are also included, and we welcome further additions. Supporting classes include time zone, duration, format and parsing.
As a flavour of Joda-Time, here's some example code:
public boolean isRentalOverdue(DateTime datetimeRented) { Period rentalPeriod = Period.days(2); return datetimeRented.plus(rentalPeriod).isBeforeNow() } public boolean isJoinedInLastThreeMonths(DateTime datetimeJoined) { Interval last3Months = new Interval(Period.months(3), new DateTime()); return last3Months.contains(datetimeJoined); } public String getBirthMonthText(YearMonthDay dateOfBirth) { return dateOfBirth.monthOfYear().getAsText(Locale.ENGLISH); }
Joda-Time has been created to radically change date and time handling is Java. The JDK classes Date and Calendar are very badly designed, have had numerous bugs and have odd performance effects. Here are some of our reasons for developing and using Joda-Time:
Calendar
.
This is clunky, and in practice it is very difficult to write another calendar system.
Joda-Time supports multiple calendar systems via a pluggable system based on the
Chronology
class.Various documentation is available:
Release 1.2.1 is the current latest release. This release is considered stable and worthy of the 1.x tag. It has extensive testing suites and has been used in production. We now recommend JDK 1.3 or later, and have performed no testing on earlier JDKs.
We will support the 1.x product line using standard Java mechanisms. The main public API will remain backwards compatible for both source and binary. The version number will change to 2.0 to indicate a change in compatibility.
For support on bugs, using the library or to volunteer please contact the mailing list (or email direct to the list via joda-interest@lists.sourceforge.net).
Alternatively, you can contact the project lead, Stephen Colebourne via scolebourne@users.sourceforge.net.