Java Reference
In-Depth Information
Gregorian Calendar: Tue Feb 11 15:45:50 CST 2014
Local Date: 2014-02-11
Local Time: 15:45:50
Local DateTime: 2014-02-11T15:45:50
Offset Date: 2014-02-11T15:45:50-06:00
Offset Time: 15:45:50-06:00
Zoned DateTime: 2014-02-11T15:45:50-06:00[America/Chicago]
Zone ID: America/Chicago
Time Zone ID: America/Chicago
Gregorian Calendar: Tue Feb 11 15:45:50 CST 2014
Summary
Through the
java.time
packages, Java 8 provides a comprehensive Date-Time API to work with date, time, and
datetime. By default, most of the classes are based on the ISO-8601 standards. The main classes are
Instant
•
LocalDate
•
LocalTime
•
LocalDateTime
•
OffsetTime
•
OffsetDateTime
•
ZonedDateTime
The
Instant
class represents an instant on the timeline and it is suitable for machines, for example, as
timestamps for event. The
LocalDate
,
LocalTime
, and
LocalDateTime
classes represents human readable date, time,
and datetime without a time zone. The
OffsetTime
and
OffsetDateTime
represent a time and datetime with a zone
offset from UTC. The
ZoneDateTime
class represents a datetime for a time zone with zone rules, which will adjust the
time according to the daylight saving time changes in the time zone.
The Date-Time API provides classes for representing an amount of time used with machines and humans. The
Duration
class represents an amount of time for machines whereas the
Period
class represents an amount of time as
perceived by humans. The Date-Time API provides extensive support for formatting and parsing date and times through
the
java.time.format.DateTimeFormatter
class. The Date-Time API supports non-ISO calendar systems through the
java.time.chrono
package. Built-in supports for Hijrah, Japanese, Minguo, and Thai Buddhist calendars are provided.
The API is extensible and supports building your calendar systems.
•