Java Reference
In-Depth Information
Date endOfTime
=
new
new
Date
(
Long
.
MAX_VALUE
);
System
.
out
.
println
(
"Java8 time overflows on "
+
endOfTime
);
The new API is in five packages, as shown in
Table 6-2
; as usual, the top-level one contains
the most commonly used pieces.
Table 6-2. New Date/Time API: Packages
Name
Description
Common classes for dates, times, instants, and durations
java.time
API for non-ISO calendar systems
java.time.chrono
Formatting classes (see
Formatting Dates and Times
)
java.time.format
java.time.temporal
Date and time access using fields, units, adjusters
Support for time zones and their rules
java.time.zone
The basic
java.time
package contains a dozen or so classes, as well as a couple of enums
Table 6-3. New Date/Time API: Basics
Description
Class
A point in time since January 1st, 1970, expressed in nanoseconds
Instant
Duration
A length of time, also expressed in nanoseconds
Human time represents times and dates as we use them in our everyday life. These classes
are listed in
Table 6-4
.