Class PeriodAdjustment

  • All Implemented Interfaces:
    Resolvable<DateAdjuster>, Serializable, org.joda.beans.Bean, org.joda.beans.ImmutableBean

    public final class PeriodAdjustment
    extends Object
    implements Resolvable<DateAdjuster>, org.joda.beans.ImmutableBean, Serializable
    An adjustment that alters a date by adding a period of calendar days, months and years.

    This adjustment adds a Period to the input date using an addition convention, followed by an adjustment to ensure the result is a valid business day.

    Addition is performed using standard calendar addition. It is not possible to add a number of business days using this class. See DaysAdjustment for an alternative that can handle addition of business days.

    There are two steps in the calculation:

    In step one, the period is added using the specified PeriodAdditionConvention.

    In step two, the result of step one is optionally adjusted to be a business day using a BusinessDayAdjustment.

    For example, a rule represented by this class might be: "the end date is 5 years after the start date, with end-of-month rule based on the last business day of the month, adjusted to be a valid London business day using the 'ModifiedFollowing' convention".

    See Also:
    Serialized Form
    • Field Detail

      • NONE

        public static final PeriodAdjustment NONE
        An instance that performs no adjustment.
    • Method Detail

      • of

        public static PeriodAdjustment of​(Period period,
                                          PeriodAdditionConvention additionConvention,
                                          BusinessDayAdjustment adjustment)
        Obtains an instance that can adjust a date by the specified period.

        When adjusting a date, the specified period is added to the input date. The business day adjustment will then be used to ensure the result is a valid business day.

        Parameters:
        period - the period to add to the input date
        additionConvention - the convention used to perform the addition
        adjustment - the business day adjustment to apply to the result of the addition
        Returns:
        the period adjustment
      • ofLastDay

        public static PeriodAdjustment ofLastDay​(Period period,
                                                 BusinessDayAdjustment adjustment)
        Obtains an instance that can adjust a date by the specified period using the last day of month convention.

        When adjusting a date, the specified period is added to the input date. The business day adjustment will then be used to ensure the result is a valid business day.

        The period must consist only of months and/or years.

        Parameters:
        period - the period to add to the input date
        adjustment - the business day adjustment to apply to the result of the addition
        Returns:
        the period adjustment
      • ofLastBusinessDay

        public static PeriodAdjustment ofLastBusinessDay​(Period period,
                                                         BusinessDayAdjustment adjustment)
        Obtains an instance that can adjust a date by the specified period using the last business day of month convention.

        When adjusting a date, the specified period is added to the input date. The business day adjustment will then be used to ensure the result is a valid business day.

        The period must consist only of months and/or years.

        Parameters:
        period - the period to add to the input date
        adjustment - the business day adjustment to apply to the result of the addition
        Returns:
        the period adjustment
      • resolve

        public DateAdjuster resolve​(ReferenceData refData)
        Resolves this adjustment using the specified reference data, returning an adjuster.

        This returns a DateAdjuster that performs the same calculation as this adjustment. It binds the holiday calendar, looked up from the reference data, into the result. As such, there is no need to pass the reference data in again.

        Specified by:
        resolve in interface Resolvable<DateAdjuster>
        Parameters:
        refData - the reference data, used to find the holiday calendar
        Returns:
        the adjuster, bound to a specific holiday calendar
      • toString

        public String toString()
        Returns a string describing the adjustment.
        Overrides:
        toString in class Object
        Returns:
        the descriptive string
      • meta

        public static PeriodAdjustment.Meta meta()
        The meta-bean for PeriodAdjustment.
        Returns:
        the meta-bean, not null
      • builder

        public static PeriodAdjustment.Builder builder()
        Returns a builder used to create an instance of the bean.
        Returns:
        the builder, not null
      • metaBean

        public PeriodAdjustment.Meta metaBean()
        Specified by:
        metaBean in interface org.joda.beans.Bean
      • getPeriod

        public Period getPeriod()
        Gets the period to be added.

        When the adjustment is performed, this period will be added to the input date.

        Returns:
        the value of the property, not null
      • getAdditionConvention

        public PeriodAdditionConvention getAdditionConvention()
        Gets the addition convention to apply.

        When the adjustment is performed, this convention is used to refine the adjusted date. The most common convention is to move the end date to the last business day of the month if the start date is the last business day of the month.

        Returns:
        the value of the property, not null
      • getAdjustment

        public BusinessDayAdjustment getAdjustment()
        Gets the business day adjustment that is performed to the result of the addition.

        This adjustment is applied to the result of the addition calculation.

        If no adjustment is required, use the 'None' business day adjustment.

        Returns:
        the value of the property, not null
      • toBuilder

        public PeriodAdjustment.Builder toBuilder()
        Returns a builder that allows this bean to be mutated.
        Returns:
        the mutable builder, not null
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object