DayOfYear is an immutable date-time object that represents a day-of-year.
It is a type-safe way of representing a day-of-year in an application.
Any field that can be derived from a day-of-year can be obtained.
This class does not store or represent a year, month, time or time-zone.
For example, the value "51" can be stored in a DayOfYear and
would represent the 51st day of any year.
This class must be treated as a value type. Do not synchronize, rely on the identity hash code or use the distinction between equals() and ==.
| Modifier and Type | Field and Description |
|---|---|
| private final int | day
The day-of-year being represented, from 1 to 366. |
| private static final long | serialVersionUID
Serialization version. |
| private static final DayOfYear[] | VALUES
Cache of singleton instances. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public Temporal | Returns: the adjusted object, not nullthe target object to be adjusted, not null temporal)Implements java. Adjusts the specified temporal object to have this day-of-year. |
| public LocalDate | |
| public LocalDate | Returns: the local date formed from this day and the specified year, not nullthe year to use, from MIN_YEAR to MAX_YEAR year)Combines this day-of-year with a year to create a |
| public int | Returns: the comparator value, negative if less, positive if greaterthe other day-of-year instance, not null other)Implements java. Compares this day-of-year to another. |
| public boolean | Returns: true if the day-of-year is the samethe other day-of-year instance, null returns false obj)Overrides java. Checks if this day-of-year is equal to another day-of-year. |
| public static DayOfYear | Returns: the day-of-year, not nullthe temporal object to convert, not null temporal)Obtains an instance of |
| public int | Returns: the value for the fieldthe field to get, not null field)Overrides default java. Gets the value of the specified field from this day-of-year as an |
| public long | Returns: the value for the fieldthe field to get, not null field)Implements java. Gets the value of the specified field from this day-of-year as a |
| public int | |
| public int | Returns: a suitable hash codeOverrides java. A hash code for this day-of-year. |
| public boolean | Returns: true if the field is supported on this day-of-year, false if notthe field to check, null returns false field)Implements java. Checks if the specified field is supported. |
| public boolean | Returns: true if the year is valid for this day-of-yearthe year to validate year)Checks if the year is valid for this day-of-year. |
| public static DayOfYear | Returns: the current day-of-year using the system clock and default time-zone, not nullObtains the current day-of-year from the system clock in the default time-zone. |
| public static DayOfYear | |
| public static DayOfYear | |
| public static DayOfYear | Returns: the day-of-year, not nullthe day-of-year to represent, from 1 to 366 dayOfYear)Obtains an instance of |
| public < the type of the result R> R | Returns: the query result, null may be returned (defined by the query)the query to invoke, not null query)Overrides default java. Queries this day-of-year using the specified query. |
| public ValueRange | Returns: the range of valid values for the field, not nullthe field to query the range for, not null field)Overrides default java. Gets the range of valid values for the specified field. |
| private Object | |
| public String | Returns: a string representation of this day-of-year, not nullOverrides java. Outputs this day-of-year as a |
| day | back to summary |
|---|---|
| private final int day The day-of-year being represented, from 1 to 366. | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Serialization version. | |
| VALUES | back to summary |
|---|---|
| private static final DayOfYear[] VALUES Cache of singleton instances. | |
| DayOfYear | back to summary |
|---|---|
| private DayOfYear(int dayOfYear) Constructor.
| |
| adjustInto | back to summary |
|---|---|
| public Temporal adjustInto(Temporal temporal) Implements java. Adjusts the specified temporal object to have this day-of-year. This returns a temporal object of the same observable type as the input with the day-of-year changed to be the same as this.
The adjustment is equivalent to using
In most cases, it is clearer to reverse the calling pattern by using
// these two lines are equivalent, but the second approach is recommended temporal = thisDay.adjustInto(temporal); temporal = temporal.with(thisDay); This instance is immutable and unaffected by this method call.
| |
| atYear | back to summary |
|---|---|
| public LocalDate atYear(Year year) Combines this day-of-year with a year to create a
This returns a This method can be used as part of a chain to produce a date: LocalDate date = day.atYear(year); The day-of-year value 366 is only valid in a leap year.
| |
| atYear | back to summary |
|---|---|
| public LocalDate atYear(int year) Combines this day-of-year with a year to create a
This returns a This method can be used as part of a chain to produce a date: LocalDate date = day.atYear(year); The day-of-year value 366 is only valid in a leap year.
| |
| compareTo | back to summary |
|---|---|
| public int compareTo(DayOfYear other) Implements java. Compares this day-of-year to another.
The comparison is based on the value of the day.
It is "consistent with equals", as defined by | |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Checks if this day-of-year is equal to another day-of-year. | |
| from | back to summary |
|---|---|
| public static DayOfYear from(TemporalAccessor temporal) Obtains an instance of
This obtains a day-of-year based on the specified temporal.
A
The conversion extracts the
This method matches the signature of the functional interface
| |
| get | back to summary |
|---|---|
| public int get(TemporalField field) Overrides default java. Gets the value of the specified field from this day-of-year as an This queries this day-of-year for the value for the specified field. The returned value will always be within the valid range of values for the field. If it is not possible to return the value, because the field is not supported or for some other reason, an exception is thrown.
If the field is a
If the field is not a
| |
| getLong | back to summary |
|---|---|
| public long getLong(TemporalField field) Implements java. Gets the value of the specified field from this day-of-year as a This queries this day-of-year for the value for the specified field. If it is not possible to return the value, because the field is not supported or for some other reason, an exception is thrown.
If the field is a
If the field is not a
| |
| getValue | back to summary |
|---|---|
| public int getValue() Gets the day-of-year value.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. A hash code for this day-of-year.
| |
| isSupported | back to summary |
|---|---|
| public boolean isSupported(TemporalField field) Implements java. Checks if the specified field is supported.
This checks if this day-of-year can be queried for the specified field.
If false, then calling the
If the field is a
ChronoField instances will return false.
If the field is not a
| |
| isValidYear | back to summary |
|---|---|
| public boolean isValidYear(int year) Checks if the year is valid for this day-of-year. This method checks whether this day-of-yearand the input year form a valid date. This can only return false for day-of-year 366.
| |
| now | back to summary |
|---|---|
| public static DayOfYear now() Obtains the current day-of-year from the system clock in the default time-zone.
This will query the Using this method will prevent the ability to use an alternate clock for testing because the clock is hard-coded.
| |
| now | back to summary |
|---|---|
| public static DayOfYear now(ZoneId zone) Obtains the current day-of-year from the system clock in the specified time-zone.
This will query the Using this method will prevent the ability to use an alternate clock for testing because the clock is hard-coded. | |
| now | back to summary |
|---|---|
| public static DayOfYear now(Clock clock) Obtains the current day-of-year from the specified clock.
This will query the specified clock to obtain the current day-of-year.
Using this method allows the use of an alternate clock for testing.
The alternate clock may be introduced using | |
| of | back to summary |
|---|---|
| public static DayOfYear of(int dayOfYear) Obtains an instance of A day-of-year object represents one of the 366 days of the year, from 1 to 366.
| |
| query | back to summary |
|---|---|
| public <R> R query(TemporalQuery<R> query) Overrides default java. Queries this day-of-year using the specified query.
This queries this day-of-year using the specified query strategy object.
The
The result of this method is obtained by invoking the
| |
| range | back to summary |
|---|---|
| public ValueRange range(TemporalField field) Overrides default java. Gets the range of valid values for the specified field. The range object expresses the minimum and maximum valid values for a field. This day-of-year is used to enhance the accuracy of the returned range. If it is not possible to return the range, because the field is not supported or for some other reason, an exception is thrown.
If the field is a
If the field is not a
| |
| readResolve | back to summary |
|---|---|
| private Object readResolve() Validates the input.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Outputs this day-of-year as a | |