WebCab Options and Futures Demo
v2.5
(J2SE Edition)

webcab.lib.calendar
Interface BusinessCalendar

All Known Implementing Classes:
AbstractBusinessCalendar

public interface BusinessCalendar

This interface defines the concept of business calendar. A business calendar tells if one day is a working day or not and several other things. It is a utility class.


Method Summary
 int daysBetween(Date start, Date end)
          Calculates and returns the number of days between two dates.
 double daysBetweenAsPercentAtYear(Date start, Date end)
          Returns the number of days between start and end dates as percent at year.
 int daysOfWeekBetween(int dayOfWeek, Date start, Date end)
          Calculates and returns the number of a certain day of week between two dates.
 String getName()
          Returns the name of this business calendar
 boolean isHoliday(Date date)
          Returns true if the specified date calendar is not working day.
 boolean isWorkingDay(Date date)
          Returns true if the specified date calendar is a working day.
 Date nextHoliday(Date date)
          Returns the next holiday day after date date.
 int nextPaymentDate(Date[] payments, Date date)
          Returns the index of the next payment date related to date.
 Date nextWorkingDay(Date date)
          Returns the next working day after date date.
 int previousPaymentDate(Date[] payments, Date date)
          Returns the index of the previous payment date related to date.
 int workingDaysBetween(Date start, Date end)
          Calculates and returns the number of working days between two dates.
 double yearsBetween(Date start, Date end)
          Returns the number of years between start and end dates.
 

Method Detail

getName

public String getName()
Returns the name of this business calendar

Returns:
the name of this business calendar

isWorkingDay

public boolean isWorkingDay(Date date)
Returns true if the specified date calendar is a working day.

Parameters:
date - the date to check
Returns:
true if the specified date calendar is a working day, false otherwise

isHoliday

public boolean isHoliday(Date date)
Returns true if the specified date calendar is not working day.

Parameters:
date - the date to check
Returns:
true if the specified date calendar is not working day, false otherwise

daysBetween

public int daysBetween(Date start,
                       Date end)
Calculates and returns the number of days between two dates. Counting days between two dates is done under the following rules:

Parameters:
start - the start date
end - the end date
Returns:
the number of days between two dates
Throws:
IllegalArgumentException - if start date is after end date

daysOfWeekBetween

public int daysOfWeekBetween(int dayOfWeek,
                             Date start,
                             Date end)
Calculates and returns the number of a certain day of week between two dates. The number of Mondays between the two dates, by example. Counting a certain day of week days between two dates is done under the following rules:

Parameters:
dayOfWeek - one of the Date.MONDAY,...,Date.SUNDAY values
start - the start date
end - the end date
Returns:
the number of a certain day of week between two dates
Throws:
IllegalArgumentException - if start date is after end date or dayOfWeek is not a day of week

workingDaysBetween

public int workingDaysBetween(Date start,
                              Date end)
Calculates and returns the number of working days between two dates. The number of working days between two working dates is the number of days between the two dates less the number of holiday days between the two dates.

Parameters:
start - the start date
end - the end date
Returns:
the number of days between two dates
Throws:
IllegalArgumentException - if start date is after end date or if one of the dates is not a working day

daysBetweenAsPercentAtYear

public double daysBetweenAsPercentAtYear(Date start,
                                         Date end)
Returns the number of days between start and end dates as percent at year. This percent is calculated using this formula:
daysBetween( start, end ) / S
where S is the sum of days of years between the start and end dates including the years of start date and end date.

Parameters:
start - the start date
end - the end date
Returns:
the number of days between start and end dates as percent at year
Throws:
IllegalArgumentException - if start date is after end date

yearsBetween

public double yearsBetween(Date start,
                           Date end)
Returns the number of years between start and end dates. This number is returned as a double value and it is calculated using daysBetweenAsPercentAtYear(Date, Date) method:
daysBetweenAsPercentAtYear(start, end) / 100
.

Parameters:
start - the start date
end - the end date
Returns:
the number of years between start and end dates
Throws:
IllegalArgumentException - if start date is after end date

nextWorkingDay

public Date nextWorkingDay(Date date)
Returns the next working day after date date.

Parameters:
date - the date used to calculate the next working day
Returns:
the next working day after date date

nextHoliday

public Date nextHoliday(Date date)
Returns the next holiday day after date date.

Parameters:
date - the date used to calculate the next holiday day
Returns:
the next holiday day after date date

previousPaymentDate

public int previousPaymentDate(Date[] payments,
                               Date date)
Returns the index of the previous payment date related to date.

Parameters:
payments - the payment dates
date - the date we are interested in
Returns:
the index of the previous payment date related to date
Throws:
IllegalArgumentException - if date is before the first payment date
See Also:
nextPaymentDate(Date[], Date)

nextPaymentDate

public int nextPaymentDate(Date[] payments,
                           Date date)
Returns the index of the next payment date related to date.

Parameters:
payments - the payment dates
date - the date we are interested in
Returns:
the index of the next payment date related to date
Throws:
IllegalArgumentException - if date is after the last payment date
See Also:
previousPaymentDate(Date[], Date)

WebCab Options and Futures Demo
v2.5
(J2SE Edition)