The Java Tutorials have been written for JDK 8.Java教程是为JDK 8编写的。Examples and practices described in this page don't take advantage of improvements introduced in later releases and might use technology no longer available.本页中描述的示例和实践没有利用后续版本中引入的改进,并且可能使用不再可用的技术。
See Java Language Changes for a summary of updated language features in Java SE 9 and subsequent releases.有关Java SE 9及其后续版本中更新的语言特性的摘要,请参阅Java语言更改。
See JDK Release Notes for information about new features, enhancements, and removed or deprecated options for all JDK releases.有关所有JDK版本的新功能、增强功能以及已删除或不推荐的选项的信息,请参阅JDK发行说明。
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.字段(TemporalField和ChronoField)和单位(TemporalUnit和ChronoUnit)在此包中定义
- 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.如果使用时区,大多数开发人员将只需要使用ZoneDateTime和ZoneId或ZoneOffset。