com.ftlabs.fisa
Class FISADate

java.lang.Object
  extended by java.util.Date
      extended by com.ftlabs.fisa.FISADate
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<java.util.Date>

public final class FISADate
extends java.util.Date

An extension of java.util.Date that contains added properties and methods for day count calculation optimization. This compromise allows for compatibility with standard comparison, manipulation and formatting operations, as well as allowing optimized access to the individual elements of this date.

See Also:
Serialized Form

Constructor Summary
FISADate(int year, int month, int day)
          Allocates a FISADate object and initializes it to the specified year, month and day.
FISADate(long date)
          Allocates a FISADate object and initializes it to represent the specified number of milliseconds since the standard base time known as "the epoch", namely January 1, 1970, 00:00:00 GMT.
 
Method Summary
 int compareTo(java.util.Date date)
          Compares a Date to this FISADate.
 int getAsInteger()
          Returns an integer representing this date, formated as yyyymmdd.
 int getBaseOffset()
          Calculates the number of days since the base date 00/00/0000.
 int getBaseOffsetNoLeap()
           
 int getDate()
          Deprecated. Use java.util.GregorianCalendar.
 int getDay()
          Returns the day of this date.
 int getHours()
          Deprecated. Use java.util.GregorianCalendar.
 int getMinutes()
          Deprecated. Use java.util.GregorianCalendar.
 int getMonth()
          Returns the month of this date.
 int getSeconds()
          Deprecated. Use java.util.GregorianCalendar.
 long getTime()
          Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this FISADate object.
 int getYear()
          Returns the year of this date.
 boolean isEom()
           
 boolean isInSync(FISADate date, InterestFrequency interestFrequency, boolean eomAdjust)
          A method to test whether this date is in sync with the provided date according to the provided interestFrequency and eomAdjust setting.
 void set(int year, int month, int day)
          Sets this FISADate to the specified year, month and day.
 void setDate(int value)
          Deprecated. Use FISADate.set( int year, int month, int day ).
 void setDay(int value)
          Deprecated. Use FISADate.set( int year, int month, int day ).
 void setHours(int value)
          Deprecated. This should not be used.
 void setMinutes(int value)
          Deprecated. This should not be used.
 void setMonth(int value)
          Deprecated. Use FISADate.set( int year, int month, int day ).
 void setSeconds(int value)
          Deprecated. This should not be used.
 void setTime(long time)
          Sets this FISADate object to represent a point in time that is time milliseconds after January 1, 1970 00:00:00 GMT.
 void setYear(int value)
          Deprecated. Use FISADate.set( int year, int month, int day ).
 java.lang.String toString()
           
 
Methods inherited from class java.util.Date
after, before, clone, equals, getTimezoneOffset, hashCode, parse, toGMTString, toLocaleString, UTC
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FISADate

public FISADate(long date)
Allocates a FISADate object and initializes it to represent the specified number of milliseconds since the standard base time known as "the epoch", namely January 1, 1970, 00:00:00 GMT.

Parameters:
date - the milliseconds since January 1, 1970, 00:00:00 GMT.

FISADate

public FISADate(int year,
                int month,
                int day)
Allocates a FISADate object and initializes it to the specified year, month and day.

Parameters:
year - the year of this date.
month - the month of this date.
day - the day of this date.
Method Detail

setTime

public void setTime(long time)
Sets this FISADate object to represent a point in time that is time milliseconds after January 1, 1970 00:00:00 GMT.

Overrides:
setTime in class java.util.Date
Parameters:
time - milliseconds after January 1, 1970 00:00:00 GMT.

getTime

public long getTime()
Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this FISADate object.

Overrides:
getTime in class java.util.Date
Returns:
the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this date.

set

public void set(int year,
                int month,
                int day)
Sets this FISADate to the specified year, month and day.

Parameters:
year - the year of this date.
month - the month of this date.
day - the day of this date.

getBaseOffset

public final int getBaseOffset()
Calculates the number of days since the base date 00/00/0000. This method is used by various day count methods.

Returns:
the number of days since the base date 00/00/0000.

getBaseOffsetNoLeap

public final int getBaseOffsetNoLeap()

compareTo

public final int compareTo(java.util.Date date)
Compares a Date to this FISADate.

Specified by:
compareTo in interface java.lang.Comparable<java.util.Date>
Overrides:
compareTo in class java.util.Date
Parameters:
date - Date to compare to this FISADate.
Returns:
an integer less than 0 if this FISADate is less than date, an integer greater than 0 if this FISADate is greater than date, or 0 if this FISADate equals date.

getAsInteger

public final int getAsInteger()
Returns an integer representing this date, formated as yyyymmdd. This is achieved using the following formula :
( year * 10000 ) + ( month * 100 ) + day.

Returns:
an integer representing this date.

getYear

public final int getYear()
Returns the year of this date. Although this is deprecated in java.util.Date, it is not for FISADate. FISADate maintains a short that holds the year for this date. The year can therefore be obtained much more quickly than using a java.util.GregorianCalendar. This method is used in various day count methods.

Overrides:
getYear in class java.util.Date
Returns:
the year of this date.

getMonth

public final int getMonth()
Returns the month of this date. Unlike java.util.Calendar, this month begins with 1 and ends with 12. Although this is deprecated in java.util.Date, it is not for FISADate. FISADate maintains a byte that holds the month for this date. The month can therefore be obtained much more quickly than using a java.util.GregorianCalendar. This method is used in various day count methods.

Overrides:
getMonth in class java.util.Date
Returns:
the month of this date.

getDay

public final int getDay()
Returns the day of this date. Although this is deprecated in java.util.Date, it is not for FISADate. FISADate maintains a byte that holds the day for this date. The day can therefore be obtained much more quickly than using a java.util.GregorianCalendar. This method is used in various day count methods.

Overrides:
getDay in class java.util.Date
Returns:
the day of this date.

isInSync

public final boolean isInSync(FISADate date,
                              InterestFrequency interestFrequency,
                              boolean eomAdjust)
A method to test whether this date is in sync with the provided date according to the provided interestFrequency and eomAdjust setting.

Parameters:
date - A date.
interestFrequency - The InterestFrequency to use.
eomAdjust - Determines whether the end of month adjustment rule should be used.
Returns:
true if this date is in sync with the provided date, otherwise false.

setYear

public void setYear(int value)
Deprecated. Use FISADate.set( int year, int month, int day ).

Throws java.lang.IllegalArgumentException(). This method is deprecated in java.util.Date.

Overrides:
setYear in class java.util.Date
Parameters:
value - the year of this date.

setMonth

public void setMonth(int value)
Deprecated. Use FISADate.set( int year, int month, int day ).

Throws java.lang.IllegalArgumentException(). This method is deprecated in java.util.Date.

Overrides:
setMonth in class java.util.Date
Parameters:
value - the month of this date.

setDate

public void setDate(int value)
Deprecated. Use FISADate.set( int year, int month, int day ).

Throws java.lang.IllegalArgumentException(). This method is deprecated in java.util.Date.

Overrides:
setDate in class java.util.Date
Parameters:
value - the date of this date.

setDay

public void setDay(int value)
Deprecated. Use FISADate.set( int year, int month, int day ).

Throws java.lang.IllegalArgumentException(). This method is deprecated in java.util.Date.

Parameters:
value - the day of this date.

setHours

public void setHours(int value)
Deprecated. This should not be used.

Throws java.lang.IllegalArgumentException(). This method is deprecated in java.util.Date. FISADate does not support a time portion.

Overrides:
setHours in class java.util.Date
Parameters:
value - the hours.

setMinutes

public void setMinutes(int value)
Deprecated. This should not be used.

Throws java.lang.IllegalArgumentException(). This method is deprecated in java.util.Date. FISADate does not support a time portion.

Overrides:
setMinutes in class java.util.Date
Parameters:
value - the minutes.

setSeconds

public void setSeconds(int value)
Deprecated. This should not be used.

Throws java.lang.IllegalArgumentException(). This method is deprecated in java.util.Date. FISADate does not support a time portion.

Overrides:
setSeconds in class java.util.Date
Parameters:
value - the seconds.

getDate

public int getDate()
Deprecated. Use java.util.GregorianCalendar.

Throws java.lang.IllegalArgumentException(). This method is deprecated in java.util.Date.

Overrides:
getDate in class java.util.Date
Returns:
the date.

getHours

public int getHours()
Deprecated. Use java.util.GregorianCalendar.

Throws java.lang.IllegalArgumentException(). This method is deprecated in java.util.Date. FISADate does not support a time portion.

Overrides:
getHours in class java.util.Date
Returns:
the hours.

getMinutes

public int getMinutes()
Deprecated. Use java.util.GregorianCalendar.

Throws java.lang.IllegalArgumentException(). This method is deprecated in java.util.Date. FISADate does not support a time portion.

Overrides:
getMinutes in class java.util.Date
Returns:
the minutes.

getSeconds

public int getSeconds()
Deprecated. Use java.util.GregorianCalendar.

Throws java.lang.IllegalArgumentException(). This method is deprecated in java.util.Date. FISADate does not support a time portion.

Overrides:
getSeconds in class java.util.Date
Returns:
the seconds.

isEom

public boolean isEom()

toString

public java.lang.String toString()
Overrides:
toString in class java.util.Date