org.jquantlib.time
Class Calendar
- java.lang.Object
-
- org.jquantlib.time.Calendar
-
- Direct Known Subclasses:
- Argentina, Australia, Brazil, Canada, China, CzechRepublic, Denmark, Finland, Germany, HongKong, Hungary, Iceland, India, Indonesia, Italy, Japan, JointCalendar, Mexico, NewZealand, Norway, NullCalendar, Poland, SaudiArabia, Singapore, Slovakia, SouthAfrica, SouthKorea, Sweden, Switzerland, Taiwan, Target, Turkey, Ukraine, UnitedKingdom, UnitedStates
public class Calendar extends java.lang.ObjectThis class provides methods for determining whether a date is a business day or a holiday for a given market, and for incrementing/decrementing a date of a given number of business days.A calendar should be defined for specific exchange holiday schedule or for general country holiday schedule. Legacy city holiday schedule calendars will be moved to the exchange/country convention.
-
-
Field Summary
Fields Modifier and Type Field and Description static java.lang.StringUKNOWN_BUSINESS_DAY_CONVENTIONstatic java.lang.StringUNKNOWN_MARKET
-
Constructor Summary
Constructors Constructor and Description Calendar()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddHoliday(Date d)Adds a date to the set of holidays for the given calendar.Dateadjust(Date date)Adjusts a non-business day to the appropriate near business day with respect to the given convention.Dateadjust(Date d, BusinessDayConvention c)Adjusts a non-business day to the appropriate near business day with respect to the given convention.Dateadvance(Date date, int n, TimeUnit unit)Advances the given date of the given number of business days and returns the result.Dateadvance(Date d, int n, TimeUnit unit, BusinessDayConvention c, boolean endOfMonth)Advances the given date of the given number of business days and returns the result.Dateadvance(Date date, Period period)Advances the given date as specified by the given period and returns the result.Dateadvance(Date date, Period period, BusinessDayConvention convention)Advances the given date as specified by the given period and returns the result.Dateadvance(Date date, Period period, BusinessDayConvention convention, boolean endOfMonth)Advances the given date as specified by the given period and returns the result.intbusinessDaysBetween(Date from, Date to)Calculates the number of business days between two given dates and returns the result.intbusinessDaysBetween(Date from, Date to, boolean includeFirst, boolean includeLast)booleanempty()Returns whether or not the calendar is initializedDateendOfMonth(Date d)Returns last business day of the month to which the given date belongsstatic booleaneq(Calendar c1, Calendar c2)static java.util.List<Date>holidayList(Calendar c, Date from, Date to, boolean includeWeekEnds)Returns the holidays between two datesbooleanisBusinessDay(Date d)Returns true if the date is a business day for the given market.booleanisEndOfMonth(Date d)Returns true if the date is last business day for the month in given market.booleanisHoliday(Date d)Returns true if the date is a holiday for the given market.booleanisWeekend(Weekday w)Returns true iff the weekday is part of the weekend for the given market.java.lang.Stringname()Returns the name of the calendar.static booleanne(Calendar c1, Calendar c2)voidremoveHoliday(Date d)Removes a date from the set of holidays for the given calendar.
-
-
-
Field Detail
-
UNKNOWN_MARKET
public static final java.lang.String UNKNOWN_MARKET
- See Also:
- Constant Field Values
-
UKNOWN_BUSINESS_DAY_CONVENTION
public static final java.lang.String UKNOWN_BUSINESS_DAY_CONVENTION
- See Also:
- Constant Field Values
-
-
Method Detail
-
empty
public boolean empty()
Returns whether or not the calendar is initialized
-
name
public java.lang.String name()
Returns the name of the calendar. warning This method is used for output and comparison between calendars. It is not meant to be used for writing switch-on-type code.- Returns:
- String - name of calendar
-
isBusinessDay
public boolean isBusinessDay(Date d)
Returns true if the date is a business day for the given market.
-
isHoliday
public boolean isHoliday(Date d)
Returns true if the date is a holiday for the given market.
-
isWeekend
public boolean isWeekend(Weekday w)
Returns true iff the weekday is part of the weekend for the given market.
-
isEndOfMonth
public boolean isEndOfMonth(Date d)
Returns true if the date is last business day for the month in given market.
-
endOfMonth
public Date endOfMonth(Date d)
Returns last business day of the month to which the given date belongs- Parameters:
d-- Returns:
- last business Date based on passed date
-
addHoliday
public void addHoliday(Date d)
Adds a date to the set of holidays for the given calendar.NOTE: This method does not affect pre-defined calendars, returning silently.
-
removeHoliday
public void removeHoliday(Date d)
Removes a date from the set of holidays for the given calendar.NOTE: This method does not affect pre-defined calendars, returning silently.
-
holidayList
public static java.util.List<Date> holidayList(Calendar c, Date from, Date to, boolean includeWeekEnds)
Returns the holidays between two dates
-
adjust
public Date adjust(Date date)
Adjusts a non-business day to the appropriate near business day with respect to the given convention.Assumes convention BusinessDayConvention.Following
-
adjust
public Date adjust(Date d, BusinessDayConvention c)
Adjusts a non-business day to the appropriate near business day with respect to the given convention.
-
advance
public Date advance(Date date, Period period, BusinessDayConvention convention)
Advances the given date as specified by the given period and returns the result.
-
advance
public Date advance(Date date, Period period, BusinessDayConvention convention, boolean endOfMonth)
Advances the given date as specified by the given period and returns the result.
-
advance
public Date advance(Date date, int n, TimeUnit unit)
Advances the given date of the given number of business days and returns the result.
-
advance
public Date advance(Date date, Period period)
Advances the given date as specified by the given period and returns the result.
-
advance
public Date advance(Date d, int n, TimeUnit unit, BusinessDayConvention c, boolean endOfMonth)
Advances the given date of the given number of business days and returns the result.
-
businessDaysBetween
public int businessDaysBetween(Date from, Date to)
Calculates the number of business days between two given dates and returns the result.
-
businessDaysBetween
public int businessDaysBetween(Date from, Date to, boolean includeFirst, boolean includeLast)
-
-
DataMelt 3.0 © DataMelt by jWork.ORG