Skip to content


August 11, 2013

Java 8 introduces a new Date/Time API in the package java.time.*. Java 7 and earlier all depended on java.util.Date and java.util.Calendar which were dated ways of representing and interacting with date-time. The need for a good Date API in the JDK spawned projects like Joda Time, which made working with dates much less painful. OpenJDK took note of Joda Time’s success and created JEP150 (JSR310) to add very similar capabilities to the JDK 8 reference implementation.

Converting from java.util.(Date|Calendar) to java.time.*

The closest class to java.util.Date is java.time.Instant. So converting between the two is provided by static methods on java.util.Date fromInstant() and toInstant(). java.util.Calendar has an instance method to convert it to a java.time.Instant

java.time package

This is the primary package for the new Date API. All classes in this package are immutable and also thread safe.


Generic API for non-ISO-8601 calendar systems. The JDK comes with 4 alternative calendars: Hijrah (lunar Islamic), Japanese Imperial, Minguo (Taiwan – Republic of China), and Thai Buddist (used in Thailand).


With a new Date API must come a new way to format those dates. This package provides new formatters and parsers with full localization support.


This package provides lower-level access to the date fields and units, and also date-time adjusters. java.time.TemporalAdjuster is an interface that returns various adjustors that can be used to create different instances of temporal classes. Using the interfaces and classes in this package, it is also possible to redefine a week. For example, in Europe the week typically starts on a Monday, while in the US it starts on a Sunday. The default ISO calendar defines a year based on whole Monday to Monday weeks.

This package provides support for timezones and also the ability to model and create new time zone rules. By default the JDK uses the IANA Time Zone Database (TZDB) as a ZoneRulesProvider, however others can be added if they extend the abstract base class ZoneRulesProvider.


From → Java

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: