Java Reference
In-Depth Information
...
}
How It Works
Repeating annotations are a handy new feature of Java 8, as they allow you to assign
multiple versions of an annotation to a single field, method, or class. To perform the
same assignment in previous releases, you had to enclose the two @Role annotations
within a @Roles group, as follows:
@Roles({
@Role(name="AUTHOR"),
@Role(name="REVIEWER")
)}
To develop a repeatable annotation, an enclosing container annotation must be cre-
ated with a field that is used to hold multiple instances of the annotation. In the recipe
example, the Roles annotation is used for holding multiple Role annotations in a re-
peatable situation. Each of the Role annotations is added to the Role[] array that is
declared within the Roles annotation.
Date-Time API
A new Date-Time API has been introduced in Java 8 and it was developed under JSR
310. The Date-Time API uses the calendar defined in ISO-8601 as the default calendar.
Therefore, the calendar is based on the Gregorian calendar system, and in this chapter,
you learn how to work with date, time, and time zone data. The Date-Time API adheres
to several design principles in an effort to be clear, fluent, immutable, and extensible.
The API uses a clear language that is concise and very well defined. It is also very flu-
ent, so code dealing with date-time data is easy to read and understand.
This introduction provides a few brief examples of the new API to get your feet
wet. To learn about the API in more detail, refer to Chapter 4 .
Search WWH ::




Custom Search