Class CalendarYear
- All Implemented Interfaces:
Serializable
,Comparable<CalendarYear>
,Iterable<PlainDate>
,TemporalAccessor
,ChronoDisplay
,ThreetenAdapter
,LocalizedPatternSupport
,ChronoInterval<PlainDate>
Represents a full gregorian calendar year as interval from 1st of January until end of December.
The only element which is registered by this class is:
Note: The current calendar year can be determined by an expression like:
nowInSystemTime()
or in a more general way
CalendarYear current = SystemClock.inLocalView().now(CalendarYear.chronology())
.
- Since:
- 3.21/4.17
- Author:
- Meno Hochschild
- See Also:
- Serialized Form
-
Field Summary
Modifier and TypeFieldDescriptionstatic ChronoElement<Integer>
Element with the proleptic iso-year without any era reference and the value range-999999999
until999999999
. -
Method Summary
Modifier and TypeMethodDescriptionCombines this year with given month to a calendar month.Combines this year with given quarter year to a calendar quarter.atDayOfYear(int dayOfYear)
Combines this year with given day of year to a calendar date.atMonth(int month)
Combines this year with given month to a calendar month.static Chronology<CalendarYear>
Yields the associated chronology.int
compareTo(CalendarYear other)
boolean
Queries if given time point belongs to this interval.boolean
static CalendarYear
Converts given JSR-310-type to a calendar year.static CalendarYear
from(GregorianDate date)
Converts given gregorian date to a calendar year.getEnd()
Yields the upper bound of this interval.getStart()
Yields the lower bound of this interval.int
getValue()
Yields the year number.int
hashCode()
boolean
Is this interval after the given time point?boolean
Is this interval before the given time point?boolean
isLeap()
Determines if this calendar year is a leap year with 366 days.iterator()
Iterates over all days of this year.int
length()
Determines the count of days belonging to this year.minus(Years<CalendarUnit> years)
Subtracts given years from this year.static CalendarYear
Obtains the current calendar year in system time.static CalendarYear
of(int year)
Creates a new instance based on given gregorian calendar year.plus(Years<CalendarUnit> years)
Adds given years to this year.static Chronology<Year>
threeten()
Obtains a bridge chronology for the typejava.time.Year
.static TimeLine<CalendarYear>
timeline()
Obtains a timeline for this type.toString()
Outputs this year number as a String in CLDR-format "uuuu".Converts this object to aTemporalAccessor
.Methods inherited from class net.time4j.range.FixedCalendarInterval
abuts, contains, isBefore, isEmpty, isFinite, isSimultaneous, streamDaily, toFlexInterval, withValue
Methods inherited from class net.time4j.engine.ChronoEntity
contains, get, get, getInt, getMaximum, getMinimum, getRegisteredElements, getTimezone, hasTimezone, isValid, isValid, isValid, matches, with, with, with, with
Methods inherited from interface net.time4j.range.ChronoInterval
intersects, isAfter
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface net.time4j.format.LocalizedPatternSupport
getFormatPattern, getFormatPattern, useDynamicFormatPattern
Methods inherited from interface net.time4j.engine.ThreetenAdapter
get, getLong, isSupported, query, range
-
Field Details
-
YEAR
Element with the proleptic iso-year without any era reference and the value range
-999999999
until999999999
.The term "proleptic" means that the rules of the gregorian calendar and the associated way of year counting is applied backward even before the introduction of gregorian calendar. The year
0
is permitted - and negative years, too. For historic year numbers, this mathematical extrapolation is not recommended and usually wrong.Format pattern symbol (for CLDR standard) can be either "u" or "y". Format example for Japanese:
ChronoFormatter<CalendarYear> f = ChronoFormatter.ofStyle(DisplayMode.FULL, Locale.JAPANESE, CalendarYear.chronology()); CalendarYear cyear = CalendarYear.of(2016); System.out.println(f.format(cyear)); // 2016年
-
-
Method Details
-
of
Creates a new instance based on given gregorian calendar year.
- Parameters:
year
- gregorian year within range-999,999,999 / +999,999,999
- Returns:
- new instance
- Throws:
IllegalArgumentException
- if given argument is out of range
-
nowInSystemTime
Obtains the current calendar year in system time.
Convenient short-cut for:
SystemClock.inLocalView().now(CalendarYear.chronology())
.- Returns:
- current calendar year in system time zone using the system clock
- Since:
- 3.24/4.20
- See Also:
SystemClock.inLocalView()
,ZonalClock.now(net.time4j.engine.Chronology)
-
at
Combines this year with given quarter year to a calendar quarter.
- Parameters:
quarter
- quarter year- Returns:
- calendar quarter
-
at
Combines this year with given month to a calendar month.
- Parameters:
month
- gregorian month- Returns:
- calendar month
-
atMonth
Combines this year with given month to a calendar month.
- Parameters:
month
- gregorian month in range 1-12- Returns:
- calendar month
- Throws:
IllegalArgumentException
- if the month is out of range
-
atDayOfYear
Combines this year with given day of year to a calendar date.
- Parameters:
dayOfYear
- day of year in range 1-365/366- Returns:
- calendar date
- Throws:
IllegalArgumentException
- if the day-of-year is out of range
-
getValue
public int getValue()Yields the year number.
- Returns:
- int
-
getStart
Description copied from interface:ChronoInterval
Yields the lower bound of this interval.
- Specified by:
getStart
in interfaceChronoInterval<PlainDate>
- Returns:
- start interval boundary
-
getEnd
Description copied from interface:ChronoInterval
Yields the upper bound of this interval.
- Specified by:
getEnd
in interfaceChronoInterval<PlainDate>
- Returns:
- end interval boundary
-
contains
Description copied from interface:ChronoInterval
Queries if given time point belongs to this interval.
- Specified by:
contains
in interfaceChronoInterval<PlainDate>
- Parameters:
temporal
- time point to be queried- Returns:
true
if given time point belongs to this interval elsefalse
-
isAfter
Description copied from interface:ChronoInterval
Is this interval after the given time point?
- Specified by:
isAfter
in interfaceChronoInterval<PlainDate>
- Parameters:
temporal
- reference time point- Returns:
true
if this interval is after given time point elsefalse
-
isBefore
Description copied from interface:ChronoInterval
Is this interval before the given time point?
- Specified by:
isBefore
in interfaceChronoInterval<PlainDate>
- Parameters:
temporal
- reference time point- Returns:
true
if this interval is before given time point elsefalse
-
isLeap
public boolean isLeap()Determines if this calendar year is a leap year with 366 days.
- Returns:
true
if it is a leap year elsefalse
- See Also:
GregorianMath.isLeapYear(int)
-
length
public int length()Determines the count of days belonging to this year.
- Returns:
- int
- See Also:
isLeap()
-
from
Converts given gregorian date to a calendar year.
- Parameters:
date
- gregorian calendar date (for examplePlainDate
- Returns:
- CalendarYear
- Throws:
IllegalArgumentException
- if given date is invalid- Since:
- 3.28/4.24
-
from
Converts given JSR-310-type to a calendar year.
- Parameters:
year
- Threeten-equivalent of this instance- Returns:
- CalendarYear
- See Also:
toTemporalAccessor()
-
plus
Adds given years to this year.
- Parameters:
years
- the count of years to be added- Returns:
- result of addition
-
minus
Subtracts given years from this year.
- Parameters:
years
- the count of years to be subtracted- Returns:
- result of subtraction
-
compareTo
- Specified by:
compareTo
in interfaceComparable<CalendarYear>
-
iterator
Iterates over all days of this year.
-
equals
-
hashCode
public int hashCode() -
toString
Outputs this year number as a String in CLDR-format "uuuu".
-
toTemporalAccessor
Description copied from interface:ThreetenAdapter
Converts this object to a
TemporalAccessor
.Any implementation is required to return a new object with a different concrete type, not this instance.
- Specified by:
toTemporalAccessor
in interfaceThreetenAdapter
- Returns:
- converted Threeten-object (always as new object)
-
chronology
Yields the associated chronology.
- Returns:
- the underlying rule engine
-
threeten
Obtains a bridge chronology for the type
java.time.Year
.- Returns:
- rule engine adapted for the type
java.time.Year
- See Also:
chronology()
-
timeline
Obtains a timeline for this type.
- Returns:
- singleton timeline
- Since:
- 5.0
-