Package org.dashbuilder.dataset.date
Enum Quarter
- java.lang.Object
-
- java.lang.Enum<Quarter>
-
- org.dashbuilder.dataset.date.Quarter
-
- All Implemented Interfaces:
Serializable,Comparable<Quarter>
public enum Quarter extends Enum<Quarter>
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static QuartergetByIndex(int index)static QuartergetByName(String name)intgetIndex()static intgetPositionInQuarter(int firstMonthOfYear, int targetMonth)Given a month (from 1 to 12) it calculates the ordinal within the quarter it belongs.static intgetQuarterFirstMonth(int firstMonthOfYear, int targetMonth)Given a month (from 1 to 12) it calculates the first month of its quarter.static QuartervalueOf(String name)Returns the enum constant of this type with the specified name.static Quarter[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Method Detail
-
values
public static Quarter[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (Quarter c : Quarter.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static Quarter valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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 type has no constant with the specified nameNullPointerException- if the argument is null
-
getIndex
public int getIndex()
-
getByIndex
public static Quarter getByIndex(int index)
-
getQuarterFirstMonth
public static int getQuarterFirstMonth(int firstMonthOfYear, int targetMonth)Given a month (from 1 to 12) it calculates the first month of its quarter.- Parameters:
firstMonthOfYear- The first month of the year considered the first month of the first quarter.targetMonth- The month we want to evaluate to which quarter belongs.- Returns:
- The first month of the target quarter for the given month.
-
getPositionInQuarter
public static int getPositionInQuarter(int firstMonthOfYear, int targetMonth)Given a month (from 1 to 12) it calculates the ordinal within the quarter it belongs.- Parameters:
firstMonthOfYear- The first month of the year considered the first month of the first quarter.targetMonth- The month we want to evaluate.- Returns:
- The position (from 0 to 2) of the target within the quarter.
-
-