Package org.drip.analytics.date
Class JulianDate
java.lang.Object
org.drip.analytics.date.JulianDate
- All Implemented Interfaces:
java.lang.Comparable<JulianDate>
public class JulianDate extends java.lang.Object implements java.lang.Comparable<JulianDate>
JulianDate provides a comprehensive representation of Julian date and date manipulation
functionality. It exports the following functionality:
The References are:
- Explicit date construction, as well as date construction from several input string formats/today
- Date Addition/Adjustment/Elapsed/Difference, add/subtract days/weeks/months/years and tenor codes
- Leap Year Functionality (number of leap days in the given interval, is the given year a leap year etc.)
- Generate the subsequent IMM date (CME IMM date, CDS/Credit ISDA IMM date etc)
- Year/Month/Day in numbers/characters
- Days Elapsed/Remaining, is EOM
- Comparison with the Other, equals/hash-code/comparator
- Export the date to a variety of date formats (Oracle, Julian, Bloomberg)
- Serialization/De-serialization to and from Byte Arrays
The References are:
- Fliegel, H. F., and T. C. van Flandern (1968): A Machine Algorithm for Processing Calendar Dates Communications of the ACM 11 657
- Fenton, D. (2001): Julian to Calendar Date Conversion http://mathforum.org/library/drmath/view/51907.html
- Module = Product Core Module
- Library = Fixed Income Analytics
- Project = Date, Cash Flow, and Cash Flow Period Measure Generation Utilities
- Package = Date and Time Creation, Manipulation, and Usage
- Author:
- Lakshmi Krishnamurthy
-
Constructor Summary
Constructors Constructor Description JulianDate(int iJulian)Create JulianDate from an Integer Julian Date Instance -
Method Summary
Modifier and Type Method Description JulianDateaddBusDays(int iDays, java.lang.String strCalendarSet)Add the given Number of Business Days and return a new JulianDate InstanceJulianDateaddDays(int iDays)Add the given Number of Days and return a JulianDate InstanceJulianDateaddMonths(int iNumMonths)Add the given Number of Months and return a New JulianDate InstanceJulianDateaddTenor(java.lang.String strTenorIn)Add the tenor to the JulianDate to create a new dateJulianDateaddTenorAndAdjust(java.lang.String strTenor, java.lang.String strCalendarSet)Add the Tenor to the JulianDate and Adjust it to create a new InstanceJulianDateaddYears(int iNumYears)Add the given Number of Years and return a new JulianDate InstanceintcompareTo(JulianDate dtOther)intdaysDiff(JulianDate dt)Difference in Days between the Current and the Input Datesbooleanequals(java.lang.Object o)inthashCode()intjulian()Return the Integer Julian DateJulianDatenextBondFuturesIMM(int iNumRollMonths, java.lang.String strCalendar)Generate the First Bond Futures IMM Date from this JulianDate according to the specified CalendarJulianDatenextCreditIMM(int iNumRollMonths)Generate the First Credit IMM roll date from this JulianDateJulianDatenextRatesFuturesIMM(int iNumRollMonths)Generate the First Rates Futures IMM Date from this JulianDateJulianDatesubtractBusDays(int iDays, java.lang.String strCalendarSet)Subtract the given Number of Business Days and return a new JulianDate InstanceJulianDatesubtractDays(int iDays)Subtract the given Number of Days and return the JulianDate InstanceJulianDatesubtractTenor(java.lang.String strTenorIn)Subtract the tenor to the JulianDate to create a new dateJulianDatesubtractTenorAndAdjust(java.lang.String strTenor, java.lang.String strCalendarSet)Subtract the tenor to the JulianDate to create a new business datejava.lang.StringtoOracleDate()Return a Trigram Representation of the Datejava.lang.StringtoString()java.lang.StringtoYYYYMMDD(java.lang.String strDelimIn)Return a Representation of Date as YYYYMMDDMethods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
-
Constructor Details
-
JulianDate
public JulianDate(int iJulian)Create JulianDate from an Integer Julian Date Instance- Parameters:
iJulian- Julian Date Integer Instance
-
-
Method Details
-
julian
public int julian()Return the Integer Julian Date- Returns:
- The Integer Julian Date
-
addDays
Add the given Number of Days and return a JulianDate Instance- Parameters:
iDays- Number of Days to be added- Returns:
- The new JulianDate
-
subtractDays
Subtract the given Number of Days and return the JulianDate Instance- Parameters:
iDays- Number of days to be subtracted- Returns:
- The JulianDate Instance
-
addBusDays
Add the given Number of Business Days and return a new JulianDate Instance- Parameters:
iDays- Number of Days to be subtractedstrCalendarSet- String representing the Calendar Set containing the Business Days- Returns:
- The new JulianDate Instance
-
subtractBusDays
Subtract the given Number of Business Days and return a new JulianDate Instance- Parameters:
iDays- Number of Days to be subtractedstrCalendarSet- String representing the Calendar Set containing the Business Days- Returns:
- The new JulianDate Instance
-
addYears
Add the given Number of Years and return a new JulianDate Instance- Parameters:
iNumYears- Number of Years to be added- Returns:
- The New JulianDate Instance
-
addMonths
Add the given Number of Months and return a New JulianDate Instance- Parameters:
iNumMonths- Number of Months to be added- Returns:
- The new JulianDate Instance
-
nextRatesFuturesIMM
Generate the First Rates Futures IMM Date from this JulianDate- Parameters:
iNumRollMonths- Number of Months to Roll- Returns:
- The IMM JulianDate Instance
-
nextBondFuturesIMM
Generate the First Bond Futures IMM Date from this JulianDate according to the specified Calendar- Parameters:
iNumRollMonths- Number of Months to RollstrCalendar- Holiday Calendar- Returns:
- The IMM JulianDate Instance
-
nextCreditIMM
Generate the First Credit IMM roll date from this JulianDate- Parameters:
iNumRollMonths- Number of Months to Roll- Returns:
- The IMM JulianDate Instance
-
addTenor
Add the tenor to the JulianDate to create a new date- Parameters:
strTenorIn- String representing the Input Tenor to add- Returns:
- The new JulianDate
-
addTenorAndAdjust
Add the Tenor to the JulianDate and Adjust it to create a new Instance- Parameters:
strTenor- The TenorstrCalendarSet- The Holiday Calendar Set- Returns:
- The new JulianDate Instance
-
subtractTenor
Subtract the tenor to the JulianDate to create a new date- Parameters:
strTenorIn- String representing the tenor to add- Returns:
- The new JulianDate
-
subtractTenorAndAdjust
public JulianDate subtractTenorAndAdjust(java.lang.String strTenor, java.lang.String strCalendarSet)Subtract the tenor to the JulianDate to create a new business date- Parameters:
strTenor- The TenorstrCalendarSet- The Holiday Calendar Set- Returns:
- The new JulianDate
-
daysDiff
Difference in Days between the Current and the Input Dates- Parameters:
dt- Input Date- Returns:
- The Difference
- Throws:
java.lang.Exception- Thrown if Input Date is Invalid
-
toOracleDate
public java.lang.String toOracleDate()Return a Trigram Representation of the Date- Returns:
- String representing the Trigram Representation of Date
-
toYYYYMMDD
public java.lang.String toYYYYMMDD(java.lang.String strDelimIn)Return a Representation of Date as YYYYMMDD- Parameters:
strDelimIn- Field Delimiter- Returns:
- String of the YYYYMMDD Representation of Date
-
equals
public boolean equals(java.lang.Object o)- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-
compareTo
- Specified by:
compareToin interfacejava.lang.Comparable<JulianDate>
-