Class CalendarQuarter
- All Implemented Interfaces:
Serializable
,Comparable<CalendarQuarter>
,Iterable<PlainDate>
,ChronoDisplay
,LocalizedPatternSupport
,ChronoInterval<PlainDate>
Represents the quarter of a gregorian calendar year as interval (like from 1st of January until end of March).
The elements registered by this class are:
Note: The current quarter of calendar year can be determined by an expression like:
nowInSystemTime()
or in a more general way
CalendarQuarter current = SystemClock.inLocalView().now(CalendarQuarter.chronology())
.
- Since:
- 3.21/4.17
- Author:
- Meno Hochschild
- See Also:
- Serialized Form
-
Field Summary
Modifier and TypeFieldDescriptionstatic ChronoElement<Quarter>
Element with the quarter of year in the value rangeQ1-Q4
.static ChronoElement<Integer>
Element with the proleptic iso-year without any era reference and the value range-999999999
until999999999
. -
Method Summary
Modifier and TypeMethodDescriptionatDayOfQuarter(int dayOfQuarter)
Combines this calendar quarter with given day of quarter year to a calendar date.Yields the date of the end of this quarter year.static Chronology<CalendarQuarter>
Yields the associated chronology.int
compareTo(CalendarQuarter other)
boolean
Queries if given time point belongs to this interval.boolean
static CalendarQuarter
from(GregorianDate date)
Converts given gregorian date to a quarter year.getEnd()
Yields the upper bound of this interval.Yields the quarter year.getStart()
Yields the lower bound of this interval.int
getYear()
Yields the year number.int
hashCode()
boolean
Is this interval after the given time point?boolean
Is this interval before the given time point?iterator()
Iterates over all days of this calendar quarter year.int
length()
Determines the count of days belonging to this quarter year.Subtracts given quarter years from this quarter year.minus(Years<CalendarUnit> years)
Subtracts given years from this quarter year.static CalendarQuarter
Obtains the current calendar quarter year in system time.static CalendarQuarter
Creates a new instance based on given gregorian calendar year and quarter year.Adds given quarter years to this quarter year.plus(Years<CalendarUnit> years)
Adds given years to this quarter year.static TimeLine<CalendarQuarter>
timeline()
Obtains a timeline for this type.toString()
Outputs this instance as a String in CLDR-format "uuuu-'Q'Q" (like "2016-Q1").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
-
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. -
QUARTER_OF_YEAR
Element with the quarter of year in the value range
Q1-Q4
.
-
-
Method Details
-
of
Creates a new instance based on given gregorian calendar year and quarter year.
- Parameters:
year
- gregorian year within range-999,999,999 / +999,999,999
quarter
- quarter year- Returns:
- new instance
- Throws:
IllegalArgumentException
- if given year is out of range
-
nowInSystemTime
Obtains the current calendar quarter year in system time.
Convenient short-cut for:
SystemClock.inLocalView().now(CalendarQuarter.chronology())
.- Returns:
- current calendar quarter year in system time zone using the system clock
- Since:
- 3.24/4.20
- See Also:
SystemClock.inLocalView()
,ZonalClock.now(net.time4j.engine.Chronology)
-
atDayOfQuarter
Combines this calendar quarter with given day of quarter year to a calendar date.
- Parameters:
dayOfQuarter
- day of quarter in range 1-90/91/92- Returns:
- calendar date
- Throws:
IllegalArgumentException
- if the day-of-quarter is out of range
-
atEndOfQuarter
Yields the date of the end of this quarter year.
- Returns:
- PlainDate
-
getYear
public int getYear()Yields the year number.
- Returns:
- int
-
getQuarter
Yields the quarter year.
- Returns:
- Quarter
-
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
-
length
public int length()Determines the count of days belonging to this quarter year.
- Returns:
- int
-
from
Converts given gregorian date to a quarter year.
- Parameters:
date
- gregorian calendar date (for examplePlainDate
- Returns:
- CalendarQuarter
- Throws:
IllegalArgumentException
- if given date is invalid- Since:
- 3.28/4.24
-
plus
Adds given years to this quarter year.
- Parameters:
years
- the count of years to be added- Returns:
- result of addition
-
plus
Adds given quarter years to this quarter year.
- Parameters:
quarters
- the count of quarter years to be added- Returns:
- result of addition
-
minus
Subtracts given years from this quarter year.
- Parameters:
years
- the count of years to be subtracted- Returns:
- result of subtraction
-
minus
Subtracts given quarter years from this quarter year.
- Parameters:
quarters
- the count of quarter years to be subtracted- Returns:
- result of subtraction
-
compareTo
- Specified by:
compareTo
in interfaceComparable<CalendarQuarter>
-
iterator
Iterates over all days of this calendar quarter year.
-
equals
-
hashCode
public int hashCode() -
toString
Outputs this instance as a String in CLDR-format "uuuu-'Q'Q" (like "2016-Q1").
-
chronology
Yields the associated chronology.
- Returns:
- the underlying rule engine
-
timeline
Obtains a timeline for this type.
- Returns:
- singleton timeline
- Since:
- 5.0
-