Class CalendarQuarter

All Implemented Interfaces:
Serializable, Comparable<CalendarQuarter>, Iterable<PlainDate>, ChronoDisplay, LocalizedPatternSupport, ChronoInterval<PlainDate>

@CalendarType("iso8601") public final class CalendarQuarter extends FixedCalendarInterval<CalendarQuarter> implements LocalizedPatternSupport

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 Details

    • YEAR

      @FormattableElement(format="u") public static final ChronoElement<Integer> YEAR

      Element with the proleptic iso-year without any era reference and the value range -999999999 until 999999999.

      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

      @FormattableElement(format="Q", alt="q") public static final ChronoElement<Quarter> QUARTER_OF_YEAR

      Element with the quarter of year in the value range Q1-Q4.

  • Method Details

    • of

      public static CalendarQuarter of(int year, Quarter quarter)

      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

      public static CalendarQuarter 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

      public PlainDate atDayOfQuarter(int dayOfQuarter)

      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

      public PlainDate atEndOfQuarter()

      Yields the date of the end of this quarter year.

      Returns:
      PlainDate
    • getYear

      public int getYear()

      Yields the year number.

      Returns:
      int
    • getQuarter

      public Quarter getQuarter()

      Yields the quarter year.

      Returns:
      Quarter
    • getStart

      public Boundary<PlainDate> getStart()
      Description copied from interface: ChronoInterval

      Yields the lower bound of this interval.

      Specified by:
      getStart in interface ChronoInterval<PlainDate>
      Returns:
      start interval boundary
    • getEnd

      public Boundary<PlainDate> getEnd()
      Description copied from interface: ChronoInterval

      Yields the upper bound of this interval.

      Specified by:
      getEnd in interface ChronoInterval<PlainDate>
      Returns:
      end interval boundary
    • contains

      public boolean contains(PlainDate temporal)
      Description copied from interface: ChronoInterval

      Queries if given time point belongs to this interval.

      Specified by:
      contains in interface ChronoInterval<PlainDate>
      Parameters:
      temporal - time point to be queried
      Returns:
      true if given time point belongs to this interval else false
    • isAfter

      public boolean isAfter(PlainDate temporal)
      Description copied from interface: ChronoInterval

      Is this interval after the given time point?

      Specified by:
      isAfter in interface ChronoInterval<PlainDate>
      Parameters:
      temporal - reference time point
      Returns:
      true if this interval is after given time point else false
    • isBefore

      public boolean isBefore(PlainDate temporal)
      Description copied from interface: ChronoInterval

      Is this interval before the given time point?

      Specified by:
      isBefore in interface ChronoInterval<PlainDate>
      Parameters:
      temporal - reference time point
      Returns:
      true if this interval is before given time point else false
    • length

      public int length()

      Determines the count of days belonging to this quarter year.

      Returns:
      int
    • from

      public static CalendarQuarter from(GregorianDate date)

      Converts given gregorian date to a quarter year.

      Parameters:
      date - gregorian calendar date (for example PlainDate
      Returns:
      CalendarQuarter
      Throws:
      IllegalArgumentException - if given date is invalid
      Since:
      3.28/4.24
    • plus

      public CalendarQuarter plus(Years<CalendarUnit> years)

      Adds given years to this quarter year.

      Parameters:
      years - the count of years to be added
      Returns:
      result of addition
    • plus

      public CalendarQuarter plus(Quarters quarters)

      Adds given quarter years to this quarter year.

      Parameters:
      quarters - the count of quarter years to be added
      Returns:
      result of addition
    • minus

      public CalendarQuarter minus(Years<CalendarUnit> years)

      Subtracts given years from this quarter year.

      Parameters:
      years - the count of years to be subtracted
      Returns:
      result of subtraction
    • minus

      public CalendarQuarter minus(Quarters quarters)

      Subtracts given quarter years from this quarter year.

      Parameters:
      quarters - the count of quarter years to be subtracted
      Returns:
      result of subtraction
    • compareTo

      public int compareTo(CalendarQuarter other)
      Specified by:
      compareTo in interface Comparable<CalendarQuarter>
    • iterator

      public Iterator<PlainDate> iterator()

      Iterates over all days of this calendar quarter year.

      Specified by:
      iterator in interface Iterable<PlainDate>
      Returns:
      Iterator
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()

      Outputs this instance as a String in CLDR-format "uuuu-'Q'Q" (like "2016-Q1").

      Overrides:
      toString in class Object
      Returns:
      String
    • chronology

      public static Chronology<CalendarQuarter> chronology()

      Yields the associated chronology.

      Returns:
      the underlying rule engine
    • timeline

      public static TimeLine<CalendarQuarter> timeline()

      Obtains a timeline for this type.

      Returns:
      singleton timeline
      Since:
      5.0