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, Ethiopic and Islamic 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 isAfterPayDay(DateTime datetime) { if (datetime.getMonthOfYear() == 2) { // February is month 2!! return datetime.getDayOfMonth() > 26; } return datetime.getDayOfMonth() > 28; } public Days daysToNewYear(LocalDate fromDate) { LocalDate newYear = fromDate.plusYears(1).withDayOfYear(1); return Days.daysBetween(fromDate, newYear); } public boolean isRentalOverdue(DateTime datetimeRented) { Period rentalPeriod = new Period().withDays(2).withHours(12); return datetimeRented.plus(rentalPeriod).isBeforeNow(); } public String getBirthMonthText(LocalDate dateOfBirth) { return dateOfBirth.monthOfYear().getAsText(Locale.ENGLISH); }
Joda-Time has been created to radically change date and time handling in 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:
Various documentation is available:
Release 2.2 is the current latest release. This release is an evolution of the 1.x codebase, not a major rewrite. It is considered stable and worthy of the 2.x tag.
Version 2.2 is a bugfix release compatible with version 2.1. See the upgrade notes for full details.
Version 2.x is almost completely source and binary compatible with version 1.x. Key changes include the use of JDK 1.5 or later, generics, and the removal of some (but not all) deprecated methods. See the upgrade notes for full details including information on the corner cases that are not compatible.
We will support the 2.x product line using standard Java mechanisms. The main public API will remain backwards compatible for both source and binary in the 2.x stream. The version number will change to 3.0 to indicate a significant change in compatibility.
Release 1.6.2 is the last v1.x release. It is compatible with JDK 1.4. Given that v2.x is essentially compatible with v1.6.2, there are no current plans for further releases in the v1.x product line.
Support on bugs, library usage or enhancement requests is available on a best efforts basis. The best approach is to use GitHub issues and Pull Requests.
Alternative approaches include the joda-interest mailing list (subscription required) and the joda-time forum.