Method Summary |
|
public static SerialDate | addDays(int days, SerialDate base) Creates a new date by adding the specified number of days to the base
date.
Parameters: days - the number of days to add (can be negative). Parameters: base - the base date. |
public static SerialDate | addMonths(int months, SerialDate base) Creates a new date by adding the specified number of months to the base
date.
If the base date is close to the end of the month, the day on the result
may be adjusted slightly: 31 May + 1 month = 30 June.
Parameters: months - the number of months to add (can be negative). Parameters: base - the base date. |
public static SerialDate | addYears(int years, SerialDate base) Creates a new date by adding the specified number of years to the base
date.
Parameters: years - the number of years to add (can be negative). Parameters: base - the base date. |
abstract public int | compare(SerialDate other) Returns the difference (in days) between this date and the specified
'other' date.
The result is positive if this date is after the 'other' date and
negative if it is before the 'other' date.
Parameters: other - the date being compared to. |
public static SerialDate | createInstance(int day, int month, int yyyy) Factory method that returns an instance of some concrete subclass of
SerialDate .
Parameters: day - the day (1-31). Parameters: month - the month (1-12). Parameters: yyyy - the year (in the range 1900 to 9999). |
public static SerialDate | createInstance(int serial) Factory method that returns an instance of some concrete subclass of
SerialDate .
Parameters: serial - the serial number for the day (1 January 1900 = 2). |
public static SerialDate | createInstance(java.util.Date date) Factory method that returns an instance of a subclass of SerialDate.
Parameters: date - A Java date object. |
abstract public int | getDayOfMonth() Returns the day of the month. |
abstract public int | getDayOfWeek() Returns the day of the week. |
public String | getDescription() Returns the description that is attached to the date. |
public SerialDate | getEndOfCurrentMonth(SerialDate base) Rolls the date forward to the last day of the month.
Parameters: base - the base date. |
public static SerialDate | getFollowingDayOfWeek(int targetWeekday, SerialDate base) Returns the earliest date that falls on the specified day-of-the-week
and is AFTER the base date.
Parameters: targetWeekday - a code for the target day-of-the-week. Parameters: base - the base date. |
public SerialDate | getFollowingDayOfWeek(int targetDOW) Returns the earliest date that falls on the specified day-of-the-week
and is AFTER this date.
Parameters: targetDOW - a code for the target day-of-the-week. |
abstract public int | getMonth() Returns the month (January = 1, February = 2, March = 3). |
public static String[] | getMonths() Returns an array of month names. |
public static String[] | getMonths(boolean shortened) Returns an array of month names.
Parameters: shortened - a flag indicating that shortened month names should be returned. |
public static SerialDate | getNearestDayOfWeek(int targetDOW, SerialDate base) Returns the date that falls on the specified day-of-the-week and is
CLOSEST to the base date.
Parameters: targetDOW - a code for the target day-of-the-week. Parameters: base - the base date. |
public SerialDate | getNearestDayOfWeek(int targetDOW) Returns the nearest date that falls on the specified day-of-the-week.
Parameters: targetDOW - a code for the target day-of-the-week. |
public static SerialDate | getPreviousDayOfWeek(int targetWeekday, SerialDate base) Returns the latest date that falls on the specified day-of-the-week and
is BEFORE the base date.
Parameters: targetWeekday - a code for the target day-of-the-week. Parameters: base - the base date. |
public SerialDate | getPreviousDayOfWeek(int targetDOW) Returns the latest date that falls on the specified day-of-the-week and
is BEFORE this date.
Parameters: targetDOW - a code for the target day-of-the-week. |
abstract public int | getYYYY() Returns the year (assume a valid range of 1900 to 9999). |
abstract public boolean | isAfter(SerialDate other) Returns true if this SerialDate represents the same date as the
specified SerialDate.
Parameters: other - the date being compared to. |
abstract public boolean | isBefore(SerialDate other) Returns true if this SerialDate represents an earlier date compared to
the specified SerialDate.
Parameters: other - The date being compared to. |
abstract public boolean | isInRange(SerialDate d1, SerialDate d2) Returns true if this
SerialDate is within the
specified range (INCLUSIVE). |
abstract public boolean | isInRange(SerialDate d1, SerialDate d2, int include) Returns true if this
SerialDate is within the
specified range (caller specifies whether or not the end-points are
included). |
public static boolean | isLeapYear(int yyyy) Determines whether or not the specified year is a leap year.
Parameters: yyyy - the year (in the range 1900 to 9999). |
abstract public boolean | isOn(SerialDate other) Returns true if this SerialDate represents the same date as the
specified SerialDate.
Parameters: other - the date being compared to. |
abstract public boolean | isOnOrAfter(SerialDate other) Returns true if this SerialDate represents the same date as the
specified SerialDate.
Parameters: other - the date being compared to. |
abstract public boolean | isOnOrBefore(SerialDate other) Returns true if this SerialDate represents the same date as the
specified SerialDate.
Parameters: other - the date being compared to. |
public static boolean | isValidMonthCode(int code) Returns true if the supplied integer code represents a valid month.
Parameters: code - the code being checked for validity. |
public static boolean | isValidWeekInMonthCode(int code) Returns true if the supplied integer code represents a valid
week-in-the-month, and false otherwise.
Parameters: code - the code being checked for validity. |
public static boolean | isValidWeekdayCode(int code) Returns true if the supplied integer code represents a
valid day-of-the-week, and false otherwise.
Parameters: code - the code being checked for validity. |
public static int | lastDayOfMonth(int month, int yyyy) Returns the number of the last day of the month, taking into account
leap years.
Parameters: month - the month. Parameters: yyyy - the year (in the range 1900 to 9999). |
public static int | leapYearCount(int yyyy) Returns the number of leap years from 1900 to the specified year
INCLUSIVE.
Note that 1900 is not a leap year.
Parameters: yyyy - the year (in the range 1900 to 9999). |
public static int | monthCodeToQuarter(int code) Returns the quarter for the specified month.
Parameters: code - the month code (1-12). |
public static String | monthCodeToString(int month) Returns a string representing the supplied month.
The string returned is the long form of the month name taken from the
default locale.
Parameters: month - the month. |
public static String | monthCodeToString(int month, boolean shortened) Returns a string representing the supplied month.
The string returned is the long or short form of the month name taken
from the default locale.
Parameters: month - the month. Parameters: shortened - if true return the abbreviation of the month. |
public static String | relativeToString(int relative) Returns a string representing the supplied 'relative'.
Need to find a better approach.
Parameters: relative - a constant representing the 'relative'. |
public void | setDescription(String description) Sets the description for the date. |
public static int | stringToMonthCode(String s) Converts a string to a month code.
This method will return one of the constants JANUARY, FEBRUARY, ...,
DECEMBER that corresponds to the string. |
public static int | stringToWeekdayCode(String s) Converts the supplied string to a day of the week.
Parameters: s - a string representing the day of the week. |
abstract public java.util.Date | toDate() Returns a java.util.Date. |
abstract public int | toSerial() Returns the serial number for the date, where 1 January 1900 = 2 (this
corresponds, almost, to the numbering system used in Microsoft Excel for
Windows and Lotus 1-2-3). |
public String | toString() Converts the date to a string. |
public static String | weekInMonthToString(int count) Returns a string corresponding to the week-in-the-month code.
Need to find a better approach.
Parameters: count - an integer code representing the week-in-the-month. |
public static String | weekdayCodeToString(int weekday) Returns a string representing the supplied day-of-the-week.
Need to find a better approach.
Parameters: weekday - the day of the week. |