Enum Quarter

    • 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 name
        NullPointerException - 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.