Joda-Time provides a quality replacement for the Java date and time classes.
Joda-Time is thede facto standard date and time library for Java prior to Java SE 8. Users are now asked to migrate tojava.time
(JSR-310).
Joda-Time is licensed under the business-friendlyApache 2.0 licence.
A selection of key features:
LocalDate
- date without timeLocalTime
- time without dateInstant
- an instantaneous point on the time-lineDateTime
- full date and time with time-zoneDateTimeZone
- a better time-zoneDuration
andPeriod
- amounts of timeInterval
- the time between two instantsVarious documentation is available:
The standard date and time classes prior to Java SE 8 are poor. By tackling this problem head-on, Joda-Time became the de facto standard date and time library for Java prior to Java SE 8.Note that from Java SE 8 onwards, users are asked to migrate tojava.time
(JSR-310) - a core part of the JDK which replaces this project.
The design allows for multiple calendar systems, while still providing a simple API. The “default” calendar is theISO8601 standard which is used by many other standards. The Gregorian, Julian, Buddhist, Coptic, Ethiopic and Islamic calendar systems are also included. 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;}
publicDays daysToNewYear(LocalDate fromDate) {LocalDate newYear = fromDate.plusYears(1).withDayOfYear(1); returnDays.daysBetween(fromDate, newYear);}
public boolean isRentalOverdue(DateTime datetimeRented) {Period rentalPeriod = newPeriod().withDays(2).withHours(12); return datetimeRented.plus(rentalPeriod).isBeforeNow();}
public String getBirthMonthText(LocalDate dateOfBirth) { return dateOfBirth.monthOfYear().getAsText(Locale.ENGLISH);}
Here are some of our reasons for developing and using Joda-Time:
getYear()
orgetDayOfWeek()
.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 theChronology
class.Release 2.13.1 is the current latest release. This release is considered stable and worthy of the 2.x tag. See thechange notes for full details.
Joda-Time requires Java SE 5 or later and hasno dependencies. There is acompile-time dependency onJoda-Convert, but this is not required at runtime thanks to the magic of annotations.
Available inMaven Central.
<dependency> <groupId>joda-time</groupId> <artifactId>joda-time</artifactId> <version>2.13.1</version></dependency>
The 2.x product line will be supported 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.
Joda-Time v2.x is an evolution of the 1.x codebase, not a major rewrite. It is almost completely source and binary compatible with version 1.x. Key changes included the use of Java SE 5 or later, generics, and the removal of some (but not all) deprecated methods. See theupgrade notes for full details when upgrading from 1.x including information on the corner cases that are not compatible. The ancient release1.6.2 was the last release to support Java SE 4 and the last v1.x release.
Java module name:org.joda.time
.
Available as part of the Tidelift Subscription.
Joda and the maintainers of thousands of other packages are working with Tidelift to deliver one enterprise subscription that covers all of the open source you use.
If you want the flexibility of open source and the confidence of commercial-grade software, this is for you.Learn more.
Please useStack Overflow for general usage questions. GitHubissues andpull requests should be used when you want to help advance the project.
Any donations to support the project are accepted viaOpenCollective.
Note that Joda-Time is considered to be a largely “finished” project. No major enhancements are planned. If using Java SE 8, please migrate tojava.time
(JSR-310).
To report a security vulnerability, please use theTidelift security contact. Tidelift will coordinate the fix and disclosure.
Copyright ©2002-2025Joda.org. All Rights Reserved.
Version: 2.13.1.Last Published: 2025-02-03.