Class Years<U extends IsoDateUnit>
- Type Parameters:
U
- generic type of year units
- All Implemented Interfaces:
Serializable
,Comparable<Years<U>>
,TimeSpan<U>
Represents a time span in gregorian or week-based years.
- Since:
- 3.21/4.17
- Author:
- Meno Hochschild
- See Also:
- Serialized Form
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.time4j.engine.TimeSpan
TimeSpan.Item<U>
-
Field Summary
Modifier and TypeFieldDescriptionstatic Years<CalendarUnit>
Constant for exactly one gregorian year.static Years<CalendarUnit>
Constant for zero gregorian years. -
Method Summary
Modifier and TypeMethodDescriptionstatic Years<CalendarUnit>
between(CalendarMonth m1, CalendarMonth m2)
Determines the difference in years between given calendar months.static Years<CalendarUnit>
between(CalendarQuarter q1, CalendarQuarter q2)
Determines the difference in years between given quarter years.between(CalendarWeek w1, CalendarWeek w2)
Determines the difference in years between given calendar weeks.static Years<CalendarUnit>
between(CalendarYear y1, CalendarYear y2)
Determines the difference in years between given calendar years.static <T extends TimePoint<? super CalendarUnit, T>>
Years<CalendarUnit>between(T t1, T t2)
Determines the temporal distance between given dates/time-points in gregorian years.static Years<CalendarUnit>
ofGregorian(int years)
Obtains a time span in given gregorian years.ofWeekBased(int years)
Obtains a time span in given week-based years.static Years<CalendarUnit>
parseGregorian(String period)
Parses the canonical ISO-8601-format "PnY" with possible preceding minus-char.parseWeekBased(String period)
LikeparseGregorian(period)
but interpretes years as week-based.Methods inherited from class net.time4j.range.SingleUnitTimeSpan
abs, addTo, compareTo, contains, equals, getAmount, getPartialAmount, getTotalLength, getUnit, hashCode, inverse, isEmpty, isNegative, isPositive, minus, minus, multipliedBy, plus, plus, subtractFrom, toStdDuration, toString, toString
-
Field Details
-
ZERO
Constant for zero gregorian years.
-
ONE
Constant for exactly one gregorian year.
-
-
Method Details
-
ofGregorian
Obtains a time span in given gregorian years.
- Parameters:
years
- count of gregorian years, maybe negative- Returns:
- time span in years
- See Also:
CalendarUnit.YEARS
-
ofWeekBased
Obtains a time span in given week-based years.
Week-based years have a length of either 364 or 371 days.
- Parameters:
years
- count of week-based years, maybe negative- Returns:
- time span in years
- See Also:
CalendarUnit.weekBasedYears()
-
between
public static <T extends TimePoint<? super CalendarUnit, T>> Years<CalendarUnit> between(T t1, T t2)Determines the temporal distance between given dates/time-points in gregorian years.
- Type Parameters:
T
- generic type of time-points- Parameters:
t1
- first time-pointt2
- second time-point- Returns:
- result of year difference
- See Also:
PlainDate
,PlainTimestamp
-
between
Determines the difference in years between given calendar years.
- Parameters:
y1
- first calendar yeary2
- second calendar year- Returns:
- year difference
-
between
Determines the difference in years between given quarter years.
- Parameters:
q1
- first quarter yearq2
- second quarter year- Returns:
- year difference
-
between
Determines the difference in years between given calendar months.
- Parameters:
m1
- first calendar monthm2
- second calendar month- Returns:
- year difference
-
between
Determines the difference in years between given calendar weeks.
- Parameters:
w1
- first calendar weekw2
- second calendar week- Returns:
- year difference
-
parseGregorian
Parses the canonical ISO-8601-format "PnY" with possible preceding minus-char.
- Parameters:
period
- the formatted string to be parsed- Returns:
- parsed instance
- Throws:
ParseException
- if given argument cannot be parsed
-
parseWeekBased
Like
parseGregorian(period)
but interpretes years as week-based.- Parameters:
period
- the formatted string to be parsed- Returns:
- parsed instance
- Throws:
ParseException
- if given argument cannot be parsed- See Also:
parseGregorian(String)
,CalendarUnit.weekBasedYears()
-