This provides additional fields and units not in the JDK.
Due to the design of the JDK, it is not possible to add new fields or units in a 100% seamless way.
The constraint is that callers must invoke methods on TemporalAccessor and Temporal
passing these fields and units as parameters, rather than calling methods on the fields and units themselves.
This affects the methods TemporalField.isSupportedBy(TemporalAccessor),
TemporalField.getFrom(TemporalAccessor),
TemporalField.adjustInto(Temporal, long),
TemporalField.rangeRefinedBy(TemporalAccessor),
TemporalUnit.isSupportedBy(Temporal),
TemporalUnit.addTo(Temporal, long) and TemporalUnit.between(Temporal, Temporal).
The underlying reason is that the JDK's TemporalAccessor and Temporal interfaces are designed
to operate in two phases: querying standard JDK fields/units, and then calling out to the actual field/unit.
In this way, the field or unit acts as a framework-level concept, and should not therefore be used
as the entrypoint for querying or manipulating a date-time object (despite what the Javadoc in the JDK says).
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final TemporalFieldThe field that represents the day-of-half.static final TemporalFieldThe field that represents the half-of-year.static final TemporalUnitUnit that represents the concept of a half-year. -
Method Summary
-
Field Details
-
DAY_OF_HALF
The field that represents the day-of-half.This field allows the day-of-half value to be queried and set. The day-of-half has values from 1 to 181 in H1 of a standard year, from 1 to 182 in H1 of a leap year and from 1 to 184 in H2.
The day-of-half can only be calculated if the day-of-year, month-of-year and year are available.
When setting this field, the value is allowed to be partially lenient, taking any value from 1 to 184. If the half has less than 184 days, then the day will end up in the following half-year.
In the resolving phase of parsing, a date can be created from a year, half-of-year and day-of-half.
In strict mode, all three fields are validated against their range of valid values. The day-of-half field is validated from 1 to 181, 182 or 184 depending on the year and half.
In smart mode, all three fields are validated against their range of valid values. The day-of-half field is validated between 1 and 184, ignoring the actual range based on the year and half. If the day-of-half exceeds the actual range, then the resulting date is in the next half-year.
In lenient mode, only the year is validated against the range of valid values. The resulting date is calculated equivalent to the following three stage approach. First, create a date on the first of January in the requested year. Then take the half-of-year, subtract one, and add the amount in halves to the date. Finally, take the day-of-half, subtract one, and add the amount in days to the date.
This unit is an immutable and thread-safe singleton.
-
HALF_OF_YEAR
The field that represents the half-of-year.This field allows the half-of-year value to be queried and set. The half-of-year has values from 1 to 2.
The half-of-year can only be calculated if the quarter-of-year is supported.
In the resolving phase of parsing, a date can be created from a year, half-of-year and day-of-half. See
DAY_OF_HALFfor details.This unit is an immutable and thread-safe singleton.
-
HALF_YEARS
Unit that represents the concept of a half-year. For the ISO calendar system, it is equal to 6 months. The estimated duration of a half-year is one half of365.2425 Days.This unit is an immutable and thread-safe singleton.
-