Documentation

The Java™ Tutorials
Hide TOC
The Date-Time Packages日期时间包
Trail: Date Time
Lesson: Date-Time Overview日期时间概述

The Date-Time Packages日期时间包

The Date-Time API consists of the primary package, java.time, and four subpackages:日期时间API由主包java.Time和四个子包组成:

java.time
The core of the API for representing date and time. 表示日期和时间的API的核心。It includes classes for date, time, date and time combined, time zones, instants, duration, and clocks. 它包括日期、时间、日期和时间组合、时区、瞬间、持续时间和时钟的类。These classes are based on the calendar system defined in ISO-8601, and are immutable and thread-safe.这些类基于ISO-8601中定义的日历系统,并且是不可变的和线程安全的。
java.time.chrono
The API for representing calendar systems other than the default ISO-8601. 用于表示除默认ISO-8601之外的日历系统的API。You can also define your own calendar system. 您还可以定义自己的日历系统。This tutorial does not cover this package in any detail.本教程不详细介绍此软件包。
java.time.format
Classes for formatting and parsing dates and times.用于格式化和分析日期和时间的类。
java.time.temporal
Extended API, primarily for framework and library writers, allowing interoperations between the date and time classes, querying, and adjustment. 扩展API,主要用于框架和库编写器,允许日期和时间类、查询和调整之间的互操作。Fields (TemporalField and ChronoField) and units (TemporalUnit and ChronoUnit) are defined in this package.字段(TemporalFieldChronoField)和单位(TemporalUnitChronoUnit)在此包中定义
java.time.zone
Classes that support time zones, offsets from time zones, and time zone rules. 支持时区、时区偏移和时区规则的类。If working with time zones, most developers will need to use only ZonedDateTime, and ZoneId or ZoneOffset.如果使用时区,大多数开发人员将只需要使用ZoneDateTimeZoneIdZoneOffset

Previous page: Date-Time Design Principles
Next page: Method Naming Conventions