Module net.finmath.lib
Class AbstractBusinessdayCalendar
java.lang.Object
net.finmath.time.businessdaycalendar.AbstractBusinessdayCalendar
- All Implemented Interfaces:
Serializable
,BusinessdayCalendar
- Direct Known Subclasses:
BusinessdayCalendarAny
,BusinessdayCalendarExcludingGivenHolidays
,BusinessdayCalendarExcludingTARGETHolidays
,BusinessdayCalendarExcludingWeekends
Base class for all business day calendars.
Implements date rolling and date adjustment.
For the supported date roll conventions see
BusinessdayCalendar.DateRollConvention
.- Version:
- 1.0
- Author:
- Christian Fries
- See Also:
- Serialized Form
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.finmath.time.businessdaycalendar.BusinessdayCalendar
BusinessdayCalendar.DateOffsetUnit, BusinessdayCalendar.DateRollConvention
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondouble[]
convertOffsetCodesToTimes(String[] dateOffsetCodes)
createDateFromDateAndOffsetCodes(LocalDate baseDate, String[] dateOffsetCodes)
getAdjustedDate(LocalDate baseDate, String dateOffsetCode, BusinessdayCalendar.DateRollConvention dateRollConvention)
Get an adjusted date for a given date and offset code.getAdjustedDate(LocalDate date, BusinessdayCalendar.DateRollConvention dateRollConvention)
Get an adjusted date for a given date.getDateFromDateAndOffsetCode(LocalDate baseDate, String dateOffsetCode)
Create a new date by "adding" a year fraction to a given base date.getRolledDate(LocalDate baseDate, int businessDays)
Find a new date by adding the given number of business days to a given base date.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.finmath.time.businessdaycalendar.BusinessdayCalendar
isBusinessday
-
Constructor Details
-
AbstractBusinessdayCalendar
public AbstractBusinessdayCalendar()
-
-
Method Details
-
getAdjustedDate
public LocalDate getAdjustedDate(LocalDate date, BusinessdayCalendar.DateRollConvention dateRollConvention)Description copied from interface:BusinessdayCalendar
Get an adjusted date for a given date.- Specified by:
getAdjustedDate
in interfaceBusinessdayCalendar
- Parameters:
date
- Given date to be adjusted.dateRollConvention
- The date roll convention to be used for the adjustment.- Returns:
- The adjusted date applying dateRollConvention to the given date.
-
getRolledDate
Description copied from interface:BusinessdayCalendar
Find a new date by adding the given number of business days to a given base date. If businessDays is zero, the method returns the unmodified base date (without adjustment).- Specified by:
getRolledDate
in interfaceBusinessdayCalendar
- Parameters:
baseDate
- The starting date.businessDays
- The number of business days from the starting date (negative values are allowed).- Returns:
- A date of a business day such that the number of business days between this one (including) and the start date (excluding) is businessDays.
-
getAdjustedDate
public LocalDate getAdjustedDate(LocalDate baseDate, String dateOffsetCode, BusinessdayCalendar.DateRollConvention dateRollConvention)Description copied from interface:BusinessdayCalendar
Get an adjusted date for a given date and offset code. First we create a new date by "adding" an offset to the base date. The offset may be given by codes like 1D, 2D, 1W, 2W, 1M, 2M, 3M, 1Y, 2Y, etc., where the letters denote the units as follows: D denotes days, W denotes weeks, M denotes month Y denotes years. Next the result is adjusted according to the given dateRollConvention.- Specified by:
getAdjustedDate
in interfaceBusinessdayCalendar
- Parameters:
baseDate
- The start date.dateOffsetCode
- String containing date offset codes (like 2D, 1W, 3M, etc.) or combination of them separated by spaces.dateRollConvention
- The date roll convention to be used for the adjustment.- Returns:
- The adjusted date applying dateRollConvention to the given date.
-
getDateFromDateAndOffsetCode
Description copied from interface:BusinessdayCalendar
Create a new date by "adding" a year fraction to a given base date.The date offset may be given by codes like 1D, 2D, 1W, 2W, 1M, 2M, 3M, 1Y, 2Y, etc., where the letters denote the units of the corresponding offset. If the date offset does not carry a letter code at the end, it will be interpreted as ACT/365 year fraction.
Date offsets can be given as (mapping to the correspondingDateOffsetUnit
):- days
- "D", "DAYS"
- business days
- "B", "BD", "BUSINESS_DAYS"
- weeks
- "W", "WEEKS"
- months
- "M", "MONTHS"
- years
- "Y", "YEARS"
The function may be used to ease the creation of maturities in spreadsheets.
- Specified by:
getDateFromDateAndOffsetCode
in interfaceBusinessdayCalendar
- Parameters:
baseDate
- The start date.dateOffsetCode
- String containing date offset codes (like 2D, 1W, 3M, etc.) or combination of them separated by spaces.- Returns:
- A date corresponding the date adding the offset to the start date.
-
createDateFromDateAndOffsetCodes
-
convertOffsetCodesToTimes
-
toString
-