Class BusinessDayAdjustment

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

    public final class BusinessDayAdjustment
    extends Object
    implements Resolvable<DateAdjuster>, org.joda.beans.ImmutableBean, Serializable
    An adjustment that alters a date if it falls on a day other than a business day.

    When processing dates in finance, it is typically intended that non-business days, such as weekends and holidays, are converted to a nearby valid business day. This class represents the necessary adjustment.

    This class combines a business day convention with a holiday calendar. To adjust a date, ReferenceData must be provided to resolve the holiday calendar.

    See Also:
    Serialized Form
    • Method Detail

      • of

        public static BusinessDayAdjustment of​(BusinessDayConvention convention,
                                               HolidayCalendarId calendar)
        Obtains an instance using the specified convention and calendar.

        When adjusting a date, the convention rule will be applied using the specified calendar.

        Parameters:
        convention - the convention used to the adjust the date if it does not fall on a business day
        calendar - the calendar that defines holidays and business days
        Returns:
        the adjuster
      • adjust

        public LocalDate adjust​(LocalDate date,
                                ReferenceData refData)
        Adjusts the date as necessary if it is not a business day.

        If the date is a business day it will be returned unaltered. If the date is not a business day, the convention will be applied.

        Parameters:
        date - the date to adjust
        refData - the reference data, used to find the holiday calendar
        Returns:
        the adjusted date
      • 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 BusinessDayAdjustment.Meta meta()
        The meta-bean for BusinessDayAdjustment.
        Returns:
        the meta-bean, not null
      • builder

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

        public BusinessDayConvention getConvention()
        Gets the convention used to the adjust the date if it does not fall on a business day.

        The convention determines whether to move forwards or backwards when it is a holiday.

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

        public HolidayCalendarId getCalendar()
        Gets the calendar that defines holidays and business days.

        When the adjustment is made, this calendar is used to skip holidays.

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

        public BusinessDayAdjustment.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