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 JulianDate
addBusDays(int iDays, java.lang.String strCalendarSet)
Add the given Number of Business Days and return a new JulianDate InstanceJulianDate
addDays(int iDays)
Add the given Number of Days and return a JulianDate InstanceJulianDate
addMonths(int iNumMonths)
Add the given Number of Months and return a New JulianDate InstanceJulianDate
addTenor(java.lang.String strTenorIn)
Add the tenor to the JulianDate to create a new dateJulianDate
addTenorAndAdjust(java.lang.String strTenor, java.lang.String strCalendarSet)
Add the Tenor to the JulianDate and Adjust it to create a new InstanceJulianDate
addYears(int iNumYears)
Add the given Number of Years and return a new JulianDate Instanceint
compareTo(JulianDate dtOther)
int
daysDiff(JulianDate dt)
Difference in Days between the Current and the Input Datesboolean
equals(java.lang.Object o)
int
hashCode()
int
julian()
Return the Integer Julian DateJulianDate
nextBondFuturesIMM(int iNumRollMonths, java.lang.String strCalendar)
Generate the First Bond Futures IMM Date from this JulianDate according to the specified CalendarJulianDate
nextCreditIMM(int iNumRollMonths)
Generate the First Credit IMM roll date from this JulianDateJulianDate
nextRatesFuturesIMM(int iNumRollMonths)
Generate the First Rates Futures IMM Date from this JulianDateJulianDate
subtractBusDays(int iDays, java.lang.String strCalendarSet)
Subtract the given Number of Business Days and return a new JulianDate InstanceJulianDate
subtractDays(int iDays)
Subtract the given Number of Days and return the JulianDate InstanceJulianDate
subtractTenor(java.lang.String strTenorIn)
Subtract the tenor to the JulianDate to create a new dateJulianDate
subtractTenorAndAdjust(java.lang.String strTenor, java.lang.String strCalendarSet)
Subtract the tenor to the JulianDate to create a new business datejava.lang.String
toOracleDate()
Return a Trigram Representation of the Datejava.lang.String
toString()
java.lang.String
toYYYYMMDD(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:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-
compareTo
- Specified by:
compareTo
in interfacejava.lang.Comparable<JulianDate>
-