object Year extends Serializable
- Annotations
- @SerialVersionUID()
- Alphabetic
- By Inheritance
- Year
- Serializable
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- val MAX_VALUE: Int
The maximum supported year, '+999,999,999'.
- val MIN_VALUE: Int
The minimum supported year, '-999,999,999'.
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def from(temporal: TemporalAccessor): Year
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 ofYear
.The conversion extracts the
year
field. The extraction is only permitted if the temporal object has an ISO chronology, or can be converted to aLocalDate
.This method matches the signature of the functional interface
TemporalQuery
allowing it to be used in queries via method reference,Year::from
.- temporal
the temporal object to convert, not null
- returns
the year, not null
- Exceptions thrown
DateTimeException
if unable to convert to a { @code Year}
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def isLeap(year: Long): Boolean
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.
- year
the year to check
- returns
true if the year is leap, false otherwise
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def now(clock: Clock): Year
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
.- clock
the clock to use, not null
- returns
the current year, not null
- def now(zone: ZoneId): Year
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.
- zone
the zone ID to use, not null
- returns
the current year using the system clock, not null
- def now: Year
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.
- returns
the current year using the system clock and default time-zone, not null
- def of(isoYear: Int): Year
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.
- isoYear
the ISO proleptic year to represent, from { @code MIN_VALUE} to { @code MAX_VALUE}
- returns
the year, not null
- Exceptions thrown
DateTimeException
if the field is invalid
- def parse(text: CharSequence, formatter: DateTimeFormatter): Year
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.
- text
the text to parse, not null
- formatter
the formatter to use, not null
- returns
the parsed year, not null
- Exceptions thrown
DateTimeParseException
if the text cannot be parsed
- def parse(text: CharSequence): Year
Obtains an instance of
Year
from a text string such as2007
.Obtains an instance of
Year
from a text string such as2007
.The string must represent a valid year. Years outside the range 0000 to 9999 must be prefixed by the plus or minus symbol.
- text
the text to parse such as "2007", not null
- returns
the parsed year, not null
- Exceptions thrown
DateTimeParseException
if the text cannot be parsed
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()