|
|
Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Page 2 of 7
Joda Time is an open source date and time API. Released by Stephen Colebourne in February 2005, it became a popular alternative to the standard Java date and time APIs. While the JSR 310: Date and Time API isn't Joda Time (due to various design flaws) it is heavily influenced by it. In fact, Colebourne is a JSR 310 co-lead.
JSR 310: Date and Time API was developed to overcome numerous problems with Java's previous date and time APIs. As a result, it has been architected around a number of important design principles:
now(), from(), and of-prefixed methods) are used as an alternative to constructors. You'll also be able to use with-prefixed methods if you need to return a copy of the current instance with additional information.
NullPointerException to be thrown. Validation methods that take object arguments and return Boolean values are an exception: they generally return
false when null is passed.
Date and Time is described by some 60 types (at the time of this writing) that are organized into a main package and four subpackages:
java.time presents classes that represent the principal date-time concepts: instants, durations, dates, times, time zones, partials,
and periods. All of this package's classes are immutable and thread-safe.
java.time.chrono provides a generic API that describes calendar systems other than the default ISO-8601 calendar system.
java.time.format presents classes for formatting and parsing date-time objects.
java.time.temporal offers field, unit, or adjustment access to a temporal object such as a date.
java.time.zone presents classes that support time zones and their rules.
The types in the java.time package should serve most of your needs. You'll work directly with the types in the other four packages only when you need
to go beyond java.time's default ISO-8601 calendar system.
To ease the transition to the new Date and Time API, the old date and time APIs have been retrofitted to interoperate with
Date and Time. For example, an Instant toInstant() method has been added to java.util.Date to convert a Date instance to an Instant instance.
Date and Time's many types can seem overwhelming. However, you'll often work with only a subset of the types in the java.time package. The remainder of the article will be a tour of the java.time types that you are most likely to use: classes used to store and manipulate machine time, local date and time, and international
time zones in your Java applications. For each of the API types I'll include a brief overview followed by one or more working
applications that demonstrate how classes are instantiated, how instances are accessed, and how instances are manipulated
to obtain new instances.
Recommended
More about the Java Date and Time API
java.time.
Popular articles in the Java 101 series