Interface PeriodAdditionConvention
-
- All Superinterfaces:
Named
public interface PeriodAdditionConvention extends Named
A convention defining how a period is added to a date.The purpose of this convention is to define how to handle the addition of a period. The default implementations include two different end-of-month rules. The convention is generally only applicable for month-based periods.
The most common implementations are provided in
PeriodAdditionConventions
. Additional implementations may be added by implementing this interface.All implementations of this interface must be immutable and thread-safe.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description LocalDate
adjust(LocalDate baseDate, Period period, HolidayCalendar calendar)
Adjusts the base date, adding the period and applying the convention rule.static ExtendedEnum<PeriodAdditionConvention>
extendedEnum()
Gets the extended enum helper.String
getName()
Gets the name that uniquely identifies this convention.boolean
isMonthBased()
Checks whether the convention requires a month-based period.static PeriodAdditionConvention
of(String uniqueName)
Obtains an instance from the specified unique name.
-
-
-
Method Detail
-
of
static PeriodAdditionConvention of(String uniqueName)
Obtains an instance from the specified unique name.- Parameters:
uniqueName
- the unique name- Returns:
- the addition convention
- Throws:
IllegalArgumentException
- if the name is not known
-
extendedEnum
static ExtendedEnum<PeriodAdditionConvention> extendedEnum()
Gets the extended enum helper.This helper allows instances of the convention to be looked up. It also provides the complete set of available instances.
- Returns:
- the extended enum helper
-
adjust
LocalDate adjust(LocalDate baseDate, Period period, HolidayCalendar calendar)
Adjusts the base date, adding the period and applying the convention rule.The adjustment occurs in two steps. First, the period is added to the based date to create the end date. Second, the end date is adjusted by the convention rules.
- Parameters:
baseDate
- the base date to add toperiod
- the period to addcalendar
- the holiday calendar to use- Returns:
- the adjusted date
-
isMonthBased
boolean isMonthBased()
Checks whether the convention requires a month-based period.A month-based period contains only months and/or years, and not days.
- Returns:
- true if the convention requires a month-based period
-
getName
String getName()
Gets the name that uniquely identifies this convention.This name is used in serialization and can be parsed using
of(String)
.
-
-