The maximum supported year, '+999,999,999'.
The minimum supported year, '-999,999,999'.
Obtains an instance of Year
from a temporal object.
Obtains an instance of Year
from a temporal object.
A TemporalAccessor
represents some form of date and time information. This factory
converts the arbitrary temporal object to an instance of Year
.
The conversion extracts the year
field. The extraction is only
permitted if the temporal object has an ISO chronology, or can be converted to a
LocalDate
.
This method matches the signature of the functional interface TemporalQuery
allowing it
to be used in queries via method reference, Year::from
.
the temporal object to convert, not null
the year, not null
DateTimeException
if unable to convert to a { @code Year}
Checks if the year is a leap year, according to the ISO proleptic calendar system rules.
Checks if the year is a leap year, according to the ISO proleptic calendar system rules.
This method applies the current rules for leap years across the whole time-line. In general, a year is a leap year if it is divisible by four without remainder. However, years divisible by 100, are not leap years, with the exception of years divisible by 400 which are.
For example, 1904 is a leap year it is divisible by 4. 1900 was not a leap year as it is divisible by 100, however 2000 was a leap year as it is divisible by 400.
The calculation is proleptic - applying the same rules into the far future and far past. This is historically inaccurate, but is correct for the ISO-8601 standard.
the year to check
true if the year is leap, false otherwise
Obtains the current year from the specified clock.
Obtains the current year from the specified clock.
This will query the specified clock to obtain the current year. Using this method allows the
use of an alternate clock for testing. The alternate clock may be introduced using dependency injection
.
the clock to use, not null
the current year, not null
Obtains the current year from the system clock in the specified time-zone.
Obtains the current year from the system clock in the specified time-zone.
This will query the system clock
to obtain the current year.
Specifying the time-zone avoids dependence on the default time-zone.
Using this method will prevent the ability to use an alternate clock for testing because the clock is hard-coded.
the zone ID to use, not null
the current year using the system clock, not null
Obtains the current year from the system clock in the default time-zone.
Obtains the current year from the system clock in the default time-zone.
This will query the system clock
in the default time-zone to
obtain the current year.
Using this method will prevent the ability to use an alternate clock for testing because the clock is hard-coded.
the current year using the system clock and default time-zone, not null
Obtains an instance of Year
.
Obtains an instance of Year
.
This method accepts a year value from the proleptic ISO calendar system.
The year 2AD/CE is represented by 2.
The year 1AD/CE is represented by 1.
The year
1BC/BCE is represented by 0.
The year 2BC/BCE is represented by -1.
the ISO proleptic year to represent, from { @code MIN_VALUE} to { @code MAX_VALUE}
the year, not null
DateTimeException
if the field is invalid
Obtains an instance of Year
from a text string using a specific formatter.
Obtains an instance of Year
from a text string using a specific formatter.
The text is parsed using the formatter, returning a year.
the text to parse, not null
the formatter to use, not null
the parsed year, not null
DateTimeParseException
if the text cannot be parsed
Obtains an instance of Year
from a text string such as 2007
.
Obtains an instance of Year
from a text string such as 2007
.
The string must represent a valid year. Years outside the range 0000 to 9999 must be prefixed by the plus or minus symbol.
the text to parse such as "2007", not null
the parsed year, not null
DateTimeParseException
if the text cannot be parsed