Top Description Fields Constructors Methods
org.threeten.extra

public final Class YearQuarter

extends Object
implements Temporal, TemporalAdjuster, Comparable<YearQuarter>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.lang.Comparable, java.time.temporal.TemporalAdjuster, java.time.temporal.Temporal, java.time.temporal.TemporalAccessor
Static Imports
java.time.temporal.ChronoField.ERA, .ChronoField.YEAR, .ChronoField.YEAR_OF_ERA, .ChronoUnit.CENTURIES, .ChronoUnit.DECADES, .ChronoUnit.ERAS, .ChronoUnit.MILLENNIA, .ChronoUnit.YEARS, .IsoFields.DAY_OF_QUARTER, .IsoFields.QUARTER_OF_YEAR, .IsoFields.QUARTER_YEARS

A year-quarter in the ISO-8601 calendar system, such as 2007-Q2.

YearQuarter is an immutable date-time object that represents the combination of a year and quarter. Any field that can be derived from a year and quarter can be obtained. A quarter is defined by Quarter and Month#firstMonthOfQuarter() - Q1, Q2, Q3 and Q4. Q1 is January to March, Q2 is April to June, Q3 is July to September and Q4 is October to December.

This class does not store or represent a day, time or time-zone. For example, the value "2nd quarter 2007" can be stored in a YearQuarter.

The ISO-8601 calendar system is the modern civil calendar system used today in most of the world. It is equivalent to the proleptic Gregorian calendar system, in which today's rules for leap years are applied for all time. For most applications written today, the ISO-8601 rules are entirely suitable. However, any application that makes use of historical dates, and requires them to be accurate will find the ISO-8601 approach unsuitable. Note that the ISO-8601 standard does not define or refer to quarters.

Implementation Requirements:

This class is immutable and thread-safe.

This class must be treated as a value type. Do not synchronize, rely on the identity hash code or use the distinction between equals() and ==.

Field Summary

Modifier and TypeField and Description
private static final DateTimeFormatter
PARSER

Parser.

private final Quarter
quarter

The quarter-of-year, not null.

private static final long
serialVersionUID

Serialization version.

private final int
year

The year.

Constructor Summary

AccessConstructor and Description
private
YearQuarter(int
the year to represent, validated from MIN_YEAR to MAX_YEAR
year
,
Quarter
the quarter-of-year to represent, validated not null
quarter
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
public Temporal

Returns:

the adjusted object, not null
adjustInto
(Temporal
the target object to be adjusted, not null
temporal
)

Implements java.time.temporal.TemporalAdjuster.adjustInto.

Adjusts the specified temporal object to have this year-quarter.

public LocalDate

Returns:

the date formed from this year-quarter and the specified day, not null
atDay
(int
the day-of-quarter to use, from 1 to 92
dayOfQuarter
)

Combines this year-quarter with a day-of-quarter to create a LocalDate.

public LocalDate

Returns:

the last valid date of this year-quarter, not null
atEndOfQuarter
()

Returns a LocalDate at the end of the quarter.

public int

Returns:

the comparator value, negative if less, positive if greater
compareTo
(YearQuarter
the other year-quarter to compare to, not null
other
)

Implements java.lang.Comparable.compareTo.

Compares this year-quarter to another

The comparison is based first on the value of the year, then on the value of the quarter.

public boolean

Returns:

true if this is equal to the other year-quarter
equals
(Object
the object to check, null returns false
obj
)

Overrides java.lang.Object.equals.

Checks if this year-quarter is equal to another year-quarter.

public String

Returns:

the formatted year-quarter string, not null
format
(DateTimeFormatter
the formatter to use, not null
formatter
)

Formats this year-quarter using the specified formatter.

public static YearQuarter

Returns:

the year-quarter, not null
from
(TemporalAccessor
the temporal object to convert, not null
temporal
)

Obtains an instance of YearQuarter from a temporal object.

public int

Returns:

the value for the field
get
(TemporalField
the field to get, not null
field
)

Overrides default java.time.temporal.TemporalAccessor.get.

Gets the value of the specified field from this year-quarter as an int.

public long

Returns:

the value for the field
getLong
(TemporalField
the field to get, not null
field
)

Implements java.time.temporal.TemporalAccessor.getLong.

Gets the value of the specified field from this year-quarter as a long.

private long
public Quarter

Returns:

the quarter-of-year, not null
getQuarter
()

Gets the quarter-of-year field using the Quarter enum.

public int

Returns:

the quarter-of-year, from 1 to 4
getQuarterValue
()

Gets the quarter-of-year field from 1 to 4.

public int

Returns:

the year, from MIN_YEAR to MAX_YEAR
getYear
()

Gets the year field.

public int

Returns:

a suitable hash code
hashCode
()

Overrides java.lang.Object.hashCode.

A hash code for this year-quarter.

public boolean

Returns:

true if this is after the specified year-quarter
isAfter
(YearQuarter
the other year-quarter to compare to, not null
other
)

Is this year-quarter after the specified year-quarter.

public boolean

Returns:

true if this point is before the specified year-quarter
isBefore
(YearQuarter
the other year-quarter to compare to, not null
other
)

Is this year-quarter before the specified year-quarter.

public boolean

Returns:

true if the year is leap, false otherwise
isLeapYear
()

Checks if the year is a leap year, according to the ISO proleptic calendar system rules.

public boolean

Returns:

true if the field is supported on this year-quarter, false if not
isSupported
(TemporalField
the field to check, null returns false
field
)

Implements java.time.temporal.TemporalAccessor.isSupported.

Checks if the specified field is supported.

public boolean

Returns:

true if the unit can be added/subtracted, false if not
isSupported
(TemporalUnit
the unit to check, null returns false
unit
)

Implements java.time.temporal.Temporal.isSupported.

Checks if the specified unit is supported.

public boolean

Returns:

true if the day is valid for this year-quarter
isValidDay
(int
the day-of-quarter to validate, from 1 to 92, invalid value returns false
dayOfQuarter
)

Checks if the day-of-quarter is valid for this year-quarter.

public int

Returns:

the length of the quarter in days, from 90 to 92
lengthOfQuarter
()

Returns the length of the quarter, taking account of the year.

public int

Returns:

366 if the year is leap, 365 otherwise
lengthOfYear
()

Returns the length of the year.

public YearQuarter

Returns:

a YearQuarter based on this year-quarter with the subtraction made, not null
minus
(TemporalAmount
the amount to subtract, not null
amountToSubtract
)

Overrides default java.time.temporal.Temporal.minus.

Returns a copy of this year-quarter with the specified amount subtracted.

public YearQuarter

Returns:

a YearQuarter based on this year-quarter with the specified amount subtracted, not null
minus
(long
the amount of the unit to subtract from the result, may be negative
amountToSubtract
,
TemporalUnit
the unit of the amount to subtract, not null
unit
)

Overrides default java.time.temporal.Temporal.minus.

Returns a copy of this year-quarter with the specified amount subtracted.

public YearQuarter

Returns:

a YearQuarter based on this year-quarter with the quarters subtracted, not null
minusQuarters
(long
the quarters to subtract, may be negative
quartersToSubtract
)

Returns a copy of this year-quarter with the specified period in quarters subtracted.

public YearQuarter

Returns:

a YearQuarter based on this year-quarter with the years subtracted, not null
minusYears
(long
the years to subtract, may be negative
yearsToSubtract
)

Returns a copy of this year-quarter with the specified period in years subtracted.

public static YearQuarter

Returns:

the current year-quarter using the system clock and default time-zone, not null
now
()

Obtains the current year-quarter from the system clock in the default time-zone.

public static YearQuarter

Returns:

the current year-quarter using the system clock, not null
now
(ZoneId
the zone ID to use, not null
zone
)

Obtains the current year-quarter from the system clock in the specified time-zone.

public static YearQuarter

Returns:

the current year-quarter, not null
now
(Clock
the clock to use, not null
clock
)

Obtains the current year-quarter from the specified clock.

public static YearQuarter

Returns:

the year-quarter, not null
of
(Year
the year to represent, not null
year
,
Quarter
the quarter-of-year to represent, not null
quarter
)

Obtains an instance of YearQuarter from a year and quarter.

public static YearQuarter

Returns:

the year-quarter, not null
of
(Year
the year to represent, not null
year
,
int
the quarter-of-year to represent, from 1 to 4
quarter
)

Obtains an instance of YearQuarter from a year and quarter.

public static YearQuarter

Returns:

the year-quarter, not null
of
(int
the year to represent, from MIN_YEAR to MAX_YEAR
year
,
Quarter
the quarter-of-year to represent, not null
quarter
)

Obtains an instance of YearQuarter from a year and quarter.

public static YearQuarter

Returns:

the year-quarter, not null
of
(int
the year to represent, from MIN_YEAR to MAX_YEAR
year
,
int
the quarter-of-year to represent, from 1 to 4
quarter
)

Obtains an instance of YearQuarter from a year and quarter.

public static YearQuarter

Returns:

the parsed year-quarter, not null
parse
(CharSequence
the text to parse such as "2007-Q2", not null
text
)

Obtains an instance of YearQuarter from a text string such as 2007-Q2.

public static YearQuarter

Returns:

the parsed year-quarter, not null
parse
(CharSequence
the text to parse, not null
text
,
DateTimeFormatter
the formatter to use, not null
formatter
)

Obtains an instance of YearQuarter from a text string using a specific formatter.

public YearQuarter

Returns:

a YearQuarter based on this year-quarter with the addition made, not null
plus
(TemporalAmount
the amount to add, not null
amountToAdd
)

Overrides default java.time.temporal.Temporal.plus.

Returns a copy of this year-quarter with the specified amount added.

public YearQuarter

Returns:

a YearQuarter based on this year-quarter with the specified amount added, not null
plus
(long
the amount of the unit to add to the result, may be negative
amountToAdd
,
TemporalUnit
the unit of the amount to add, not null
unit
)

Implements java.time.temporal.Temporal.plus.

Returns a copy of this year-quarter with the specified amount added.

public YearQuarter

Returns:

a YearQuarter based on this year-quarter with the quarters added, not null
plusQuarters
(long
the quarters to add, may be negative
quartersToAdd
)

Returns a copy of this year-quarter with the specified period in quarters added.

public YearQuarter

Returns:

a YearQuarter based on this year-quarter with the years added, not null
plusYears
(long
the years to add, may be negative
yearsToAdd
)

Returns a copy of this year-quarter with the specified period in years added.

public Stream<YearQuarter>

Returns:

a sequential Stream for the range of YearQuarter values
quartersUntil
(YearQuarter
the end year-quarter, exclusive, not null
endExclusive
)

Returns a sequential ordered stream of year-quarter.

public <
the type of the result
R
>
R

Returns:

the query result, null may be returned (defined by the query)
query
(TemporalQuery<R>
the query to invoke, not null
query
)

Overrides default java.time.temporal.TemporalAccessor.query.

Queries this year-quarter using the specified query.

public ValueRange

Returns:

the range of valid values for the field, not null
range
(TemporalField
the field to query the range for, not null
field
)

Overrides default java.time.temporal.TemporalAccessor.range.

Gets the range of valid values for the specified field.

private Object

Returns:

the valid object, not null
readResolve
()

Validates the input.

public String

Returns:

a string representation of this year-quarter, not null
toString
()

Overrides java.lang.Object.toString.

Outputs this year-quarter as a String, such as 2007-Q2.

public long

Returns:

the amount of time between this year-quarter and the end year-quarter
until
(Temporal
the end date, exclusive, which is converted to a YearQuarter, not null
endExclusive
,
TemporalUnit
the unit to measure the amount in, not null
unit
)

Implements java.time.temporal.Temporal.until.

Calculates the amount of time until another year-quarter in terms of the specified unit.

private YearQuarter

Returns:

the year-quarter, not null
with
(int
the year to represent, validated from MIN_YEAR to MAX_YEAR
newYear
,
Quarter
the quarter-of-year to represent, validated not null
newQuarter
)

Returns a copy of this year-quarter with the new year and quarter, checking to see if a new object is in fact required.

public YearQuarter

Returns:

a YearQuarter based on this with the adjustment made, not null
with
(TemporalAdjuster
the adjuster to use, not null
adjuster
)

Overrides default java.time.temporal.Temporal.with.

Returns an adjusted copy of this year-quarter.

public YearQuarter

Returns:

a YearQuarter based on this with the specified field set, not null
with
(TemporalField
the field to set in the result, not null
field
,
long
the new value of the field in the result
newValue
)

Implements java.time.temporal.Temporal.with.

Returns a copy of this year-quarter with the specified field set to a new value.

public YearQuarter

Returns:

a YearQuarter based on this year-quarter with the requested quarter, not null
withQuarter
(int
the quarter-of-year to set in the returned year-quarter, from 1 to 4
quarter
)

Returns a copy of this YearQuarter with the quarter-of-year altered.

public YearQuarter

Returns:

a YearQuarter based on this year-quarter with the requested year, not null
withYear
(int
the year to set in the returned year-quarter, from MIN_YEAR to MAX_YEAR
year
)

Returns a copy of this YearQuarter with the year altered.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait