Enum Class Quarter
- All Implemented Interfaces:
Serializable
,Comparable<Quarter>
,java.lang.constant.Constable
,Function<PlainDate,PlainDate>
,Predicate<GregorianDate>
,UnaryOperator<PlainDate>
,ChronoCondition<GregorianDate>
,ChronoOperator<PlainDate>
Represents a quarter (in most cases of a year).
- Author:
- Meno Hochschild
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdjusts given entity and yields a changed copy of argument.getDisplayName(Locale locale)
Equivalent to the expressiongetDisplayName(locale, TextWidth.WIDE, OutputContext.FORMAT)
.getDisplayName(Locale locale, TextWidth width, OutputContext context)
Gets the description text dependent on the locale and style parameters.int
getValue()
Gets the corresponding numerical value.next()
Rolls to the next quarter.static Quarter
parse(CharSequence text, Locale locale, TextWidth width, OutputContext context)
Tries to interprete given text as quarter of year.previous()
Rolls to the previous quarter.roll(int quarters)
Rolls by given amount of quarters.boolean
test(GregorianDate context)
Decides if given context matches this condition.static Quarter
valueOf(int quarter)
Gets the enum-constant which corresponds to the given numerical value.static Quarter
Returns the enum constant of this class with the specified name.static Quarter[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class java.lang.Enum
compareTo, describeConstable, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Enum Constant Details
-
Q1
First quarter with the numerical value
1
. -
Q2
Second quarter with the numerical value
2
. -
Q3
Third quarter with the numerical value
3
. -
Q4
Last quarter with the numerical value
4
.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
valueOf
Gets the enum-constant which corresponds to the given numerical value.
- Parameters:
quarter
- value in the range [1-4]- Returns:
- enum
- Throws:
IllegalArgumentException
- if given argument is out of range
-
getValue
public int getValue()Gets the corresponding numerical value.
- Returns:
- int (Q1 = 1, Q2 = 2, Q3 = 3, Q4 = 4)
-
next
Rolls to the next quarter.
The result is
Q1
if this method is applied onQ4
.- Returns:
- next quarter rolling at last quarter
-
previous
Rolls to the previous quarter.
The result is
Q4
if this method is applied onQ1
.- Returns:
- previous quarter rolling at first quarter
-
roll
Rolls by given amount of quarters.
- Parameters:
quarters
- count of quarters (maybe negative)- Returns:
- result of rolling operation
-
getDisplayName
Equivalent to the expression
getDisplayName(locale, TextWidth.WIDE, OutputContext.FORMAT)
.- Parameters:
locale
- language setting- Returns:
- descriptive text (long form, never
null
) - See Also:
getDisplayName(Locale, TextWidth, OutputContext)
-
getDisplayName
Gets the description text dependent on the locale and style parameters.
The second argument controls the width of description while the third argument is only relevant for languages which make a difference between stand-alone forms and embedded text forms (does not matter in English).
- Parameters:
locale
- language settingwidth
- text widthcontext
- output context- Returns:
- descriptive text for given locale and style (never
null
)
-
parse
public static Quarter parse(CharSequence text, Locale locale, TextWidth width, OutputContext context) throws ParseExceptionTries to interprete given text as quarter of year.
- Parameters:
text
- the text to be parsedlocale
- language settingwidth
- expected text widthcontext
- expected output context- Returns:
- the parsed quarter of year if successful
- Throws:
ParseException
- if parsing fails- Since:
- 3.33/4.28
- See Also:
getDisplayName(Locale, TextWidth, OutputContext)
-
test
Description copied from interface:ChronoCondition
Decides if given context matches this condition.
Due to better readability it is recommended to use following equivalent approach instead of this method::
import static net.time4j.Weekday.SATURDAY; import static net.time4j.Month.JANUARY; PlainDate date = PlainDate.of(2014, JANUARY, 25); System.out.println(SATURDAY.test(date)); // direct use System.out.println(date.matches(SATURDAY)); // recommended callback
- Specified by:
test
in interfaceChronoCondition<GregorianDate>
- Specified by:
test
in interfacePredicate<GregorianDate>
- Parameters:
context
- context as base of testing this condition- Returns:
true
if given time context matches this condition elsefalse
-
apply
Description copied from interface:ChronoOperator
Adjusts given entity and yields a changed copy of argument.
Will be called by
ChronoEntity.with(ChronoOperator)
.
-