Class AccountingChronologyBuilder


  • public final class AccountingChronologyBuilder
    extends java.lang.Object
    Builder to create Accounting calendars.

    Accounting calendars require setup before use, given how they are used. The following information is required:

    • ending day-of-week - The day-of-week on which a given accounting year ends.
    • last-in-month vs. nearest-end-of-month - Whether the ending day-of-week is the last in the month, or the nearest to the end of the month (will sometimes be in the next month.
    • month end - Which Gregorian/ISO end-of-month the year ends in/is nearest to.
    • year division - How many 'months' (periods) to divide the accounting year into, and how many weeks are in each.
    • leap-week month - Which month will have the leap 'week' added to it. In practice this is probably the last one, but this does not seem to be required.

    There are approximately 7 x 2 x 12 x 4 x 12/13 = 4032 combinations.

    Implementation Requirements

    This class is a mutable builder suitable for use from a single thread.
    • Constructor Detail

      • AccountingChronologyBuilder

        public AccountingChronologyBuilder()
        Constructs a new instance of the builder.
    • Method Detail

      • endsOn

        public AccountingChronologyBuilder endsOn​(java.time.DayOfWeek endsOn)
        Sets the day-of-week on which a given Accounting calendar year ends.
        Parameters:
        endsOn - The day-of-week on which a given Accounting calendar year ends.
        Returns:
        this, for chaining, not null.
      • nearestEndOf

        public AccountingChronologyBuilder nearestEndOf​(java.time.Month end)
        Sets the Gregorian/ISO month-end which a given Accounting calendar year ends nearest to. Calendars setup this way will occasionally end in the start of the next month. For example, for July, the month ends on any day from July 28th to August 3rd.
        Parameters:
        end - The Gregorian/ISO month-end a given Accounting calendar year ends nearest to.
        Returns:
        this, for chaining, not null.
      • inLastWeekOf

        public AccountingChronologyBuilder inLastWeekOf​(java.time.Month end)
        Sets the Gregorian/ISO month-end in which a given Accounting calendar year ends. Calendars setup this way will always end in the last week of the given month. For example, for July, the month ends on any day from July 25th to July 31st.
        Parameters:
        end - The Gregorian/ISO month-end a given Accounting calendar year ends in the last week of.
        Returns:
        this, for chaining, not null.
      • withDivision

        public AccountingChronologyBuilder withDivision​(AccountingYearDivision division)
        Sets how a given Accounting year will be divided.
        Parameters:
        division - How to divide a given calendar year.
        Returns:
        this, for chaining, not null.
      • leapWeekInMonth

        public AccountingChronologyBuilder leapWeekInMonth​(int leapWeekInMonth)
        Sets the month in which the leap-week occurs.
        Parameters:
        leapWeekInMonth - The month in which the leap-week occurs.
        Returns:
        this, for chaining, not null.
      • toChronology

        public AccountingChronology toChronology()
        Completes this builder by creating the AccountingChronology.
        Returns:
        the created chronology, not null.
        Throws:
        java.time.DateTimeException - if the chronology cannot be built.