|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
E
- a representation of a date, typically JDK: Date, Calendar;
Joda:LocalDate, YearMonthDaypublic interface DateCalculator<E>
A DateCalculator is a lightweight container with an optional reference to a set of holidays, a WorkingWeek (Mon-Fri by default), a startDate and a current business date. The Calculator also uses a HolidayHandler to determine what to do when the calculated current Business Date falls on a weekend or holiday (non-working day). The CurrentDate date is changed everytime that the moveByDays or moveByBusinessDays methods are called. 'E' will be parameterized to be a Date-like class, i.e. java.util.Date or java.util.Calendar (and LocalDate or YearMonthDay for Joda-time).
Method Summary | |
---|---|
java.util.List<E> |
calculateTenorDates(java.util.List<Tenor> tenors)
Calculate a series of Tenor codes in one go based on current day, this does NOT change the current business date. |
java.util.List<E> |
calculateTenorDates(java.util.List<Tenor> tenors,
int spotLag)
Calculate a series of Tenor codes in one go based on SPOT day (calculated with the spot lag), this does NOT change the current business date. |
DateCalculator<E> |
combine(DateCalculator<E> calculator)
Allows DateCalculators to be combined into a new one, the startDate and currentBusinessDate will be the ones from the existing calendar (not the parameter one). |
E |
getCurrentBusinessDate()
Gives the current business date held by the calculator. |
int |
getCurrentIncrement()
return the current increment in the calculator, this is used by the handler. |
HolidayCalendar<E> |
getHolidayCalendar()
Returns an immutable version of the HolidayCalendar. |
java.lang.String |
getHolidayHandlerType()
Gives the name of the holiday handler algorithm, see HolidayHandlerType for some standard values. |
java.lang.String |
getName()
This is typically the name of the associated set of holidays. |
java.util.Set<E> |
getNonWorkingDays()
Deprecated. use getHolidayCalendar, likely to be REMOVED next release. |
E |
getStartDate()
Gives the startDate of this calculator (immutable once set via setStartDate). |
boolean |
isCurrentDateNonWorking()
Is the current business day a non-working day, this is useful if the calculator does not have any algorithm to change the date when it falls on a non-working day. |
boolean |
isNonWorkingDay(E date)
Is the given date a non working day, i.e. |
boolean |
isWeekend(E date)
Is the given date falling on a weekend, according to the WorkingWeek. |
DateCalculator<E> |
moveByBusinessDays(int businessDays)
This changes the current business date held in the calculator, it moves the current date by a number of business days, this means that if a date is either a 'weekend' or holiday along the way, it will be skipped acording to the holiday handler and not count towards the number of days to move. |
DateCalculator<E> |
moveByDays(int days)
This changes the current business date held in the calculator, it moves the new current business date by the number of days and, if it falls on a weekend or holiday, moves it further according to the HolidayHandler given in this DateCalculator. |
DateCalculator<E> |
moveByTenor(Tenor tenor)
Move the current date by a given tenor, please note that all tenors are relative to the CURRENT day (and NOT from spot). |
DateCalculator<E> |
moveByTenor(Tenor tenor,
int spotLag)
Move the current date by a given tenor, please note that all tenors are relative to the SPOT day which is a number of days from the current date. |
E |
setCurrentBusinessDate(E date)
Gives a current business date, it may be moved acording to the HolidayHandler algorithm if it falls on a non-working day. |
void |
setCurrentIncrement(int increment)
This would be used by delegate methods to detect if the increment if positive or negative (this will allow us to define a Handler that can act as Forward if positive and Backward if negative). |
void |
setHolidayCalendar(HolidayCalendar<E> calendar)
This is typically used at the construction of a DateCalculator to give a reference to a Holiday Calendar, if not the case, the calculator will make an immutable copy of the HolidayCalendar. |
void |
setNonWorkingDays(java.util.Set<E> holidays)
Deprecated. should use setHolidayCalendar |
void |
setStartDate(E startDate)
Setting the start date also sets the current business date (and if this is a non-working day, the current business date will be moved to the next business day acording to the HolidayHandler algorithm given). |
void |
setWorkingWeek(WorkingWeek week)
Allows user to define what their Working Week should be (default is Mon-Fri). |
Method Detail |
---|
java.lang.String getName()
void setStartDate(E startDate)
startDate
- the reference date for this calculator, the current business
date is also updated and may be moved if it falls on a non
working day (holiday/weekend).E getStartDate()
E getCurrentBusinessDate()
boolean isWeekend(E date)
boolean isNonWorkingDay(E date)
boolean isCurrentDateNonWorking()
@Deprecated void setNonWorkingDays(java.util.Set<E> holidays)
holidays
- the holiday (if null, an empty set will be put in place)void setHolidayCalendar(HolidayCalendar<E> calendar)
holidays
- the holiday calendar (if null, no holidays taken into account)@Deprecated java.util.Set<E> getNonWorkingDays()
HolidayCalendar<E> getHolidayCalendar()
void setWorkingWeek(WorkingWeek week)
week
- an immutable definition of a week.E setCurrentBusinessDate(E date)
date
-
java.lang.String getHolidayHandlerType()
DateCalculator<E> moveByDays(int days)
days
- number of days (can be <0 or >0)
DateCalculator<E> moveByBusinessDays(int businessDays)
businessDays
- (can be <0 or >0)
java.lang.IllegalArgumentException
- if the HolidayHandlerType is (MODIFIED_PRECEDING or
BACKWARD) and businessDays > 0 or (MODIFIED_FOLLOWING or
FORWARD) and businessDays < 0DateCalculator<E> combine(DateCalculator<E> calculator)
calculator
- return the same DateCalculator if calender is null or the
original calendar (but why would you want to do that?)
java.lang.IllegalArgumentException
- if both calendars have different types of HolidayHandlers or
WorkingWeek; Also, it is required that BOTH calendars either
have Early/Late Boundaries or none.DateCalculator<E> moveByTenor(Tenor tenor, int spotLag)
tenor
- the Tenor to reach.spotLag
- number of days to "spot" days, this can vary from one market
to the other. It is sometimes called "settlement interval"
or "offset".
DateCalculator<E> moveByTenor(Tenor tenor)
tenor
- the Tenor to reach.
java.util.List<E> calculateTenorDates(java.util.List<Tenor> tenors)
java.util.List<E> calculateTenorDates(java.util.List<Tenor> tenors, int spotLag)
int getCurrentIncrement()
void setCurrentIncrement(int increment)
increment
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |