Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.jfree.date.SerialDate
public abstract class SerialDate
extends java.lang.Object
implements Comparable, Serializable, MonthConstants
Field Summary | |
static DateFormatSymbols |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
Fields inherited from interface org.jfree.date.MonthConstants | |
APRIL , AUGUST , DECEMBER , FEBRUARY , JANUARY , JULY , JUNE , MARCH , MAY , NOVEMBER , OCTOBER , SEPTEMBER |
Constructor Summary | |
|
Method Summary | |
static SerialDate |
|
static SerialDate |
|
static SerialDate |
|
abstract int |
|
static SerialDate |
|
static SerialDate |
|
static SerialDate |
|
abstract int |
|
abstract int |
|
String |
|
SerialDate |
|
SerialDate |
|
static SerialDate |
|
abstract int |
|
static String[] |
|
static String[] |
|
SerialDate |
|
static SerialDate |
|
SerialDate |
|
static SerialDate |
|
abstract int |
|
abstract boolean |
|
abstract boolean |
|
abstract boolean |
|
abstract boolean |
|
static boolean |
|
abstract boolean |
|
abstract boolean |
|
abstract boolean |
|
static boolean |
|
static boolean |
|
static boolean |
|
static int |
|
static int |
|
static int |
|
static String |
|
static String |
|
static String |
|
void |
|
static int |
|
static int |
|
abstract java.util.Date |
|
abstract int |
|
String |
|
static String |
|
static String |
|
public static final int FIRST_WEEK_IN_MONTH
A useful constant for referring to the first week in a month.
- Field Value:
- 1
public static final int FOLLOWING
Useful constant for specifying a day of the week relative to a fixed date.
- Field Value:
- 1
public static final int FOURTH_WEEK_IN_MONTH
A useful constant for referring to the fourth week in a month.
- Field Value:
- 4
public static final int FRIDAY
Useful constant for Friday. Equivalent to java.util.Calendar.FRIDAY.
public static final int LAST_WEEK_IN_MONTH
A useful constant for referring to the last week in a month.
- Field Value:
- 0
public static final int MAXIMUM_YEAR_SUPPORTED
The highest year value supported by this date format.
- Field Value:
- 9999
public static final int MINIMUM_YEAR_SUPPORTED
The lowest year value supported by this date format.
- Field Value:
- 1900
public static final int MONDAY
Useful constant for Monday. Equivalent to java.util.Calendar.MONDAY.
public static final int NEAREST
Useful constant for specifying a day of the week relative to a fixed date.
- Field Value:
- 0
public static final int PRECEDING
Useful constant for specifying a day of the week relative to a fixed date.
- Field Value:
- -1
public static final int SATURDAY
Useful constant for Saturday. Equivalent to java.util.Calendar.SATURDAY.
public static final int SECOND_WEEK_IN_MONTH
A useful constant for referring to the second week in a month.
- Field Value:
- 2
public static final int SERIAL_LOWER_BOUND
The serial number for 1 January 1900.
- Field Value:
- 2
public static final int SERIAL_UPPER_BOUND
The serial number for 31 December 9999.
- Field Value:
- 2958465
public static final int SUNDAY
Useful constant for Sunday. Equivalent to java.util.Calendar.SUNDAY.
public static final int THIRD_WEEK_IN_MONTH
A useful constant for referring to the third week in a month.
- Field Value:
- 3
public static final int THURSDAY
Useful constant for Thrusday. Equivalent to java.util.Calendar.THURSDAY.
public static final int TUESDAY
Useful constant for Tuesday. Equivalent to java.util.Calendar.TUESDAY.
public static final int WEDNESDAY
Useful constant for Wednesday. Equivalent to java.util.Calendar.WEDNESDAY.
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).base
- the base date.
- Returns:
- a new 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).base
- the base date.
- Returns:
- a new 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).base
- the base date.
- Returns:
- A new date.
public abstract 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.
- Returns:
- the difference between this and the other date.
public static SerialDate createInstance(int serial)
Factory method that returns an instance of some concrete subclass ofSerialDate
.
- Parameters:
serial
- the serial number for the day (1 January 1900 = 2).
- Returns:
- a instance of SerialDate.
public static SerialDate createInstance(int day, int month, int yyyy)
Factory method that returns an instance of some concrete subclass ofSerialDate
.
- Parameters:
day
- the day (1-31).month
- the month (1-12).yyyy
- the year (in the range 1900 to 9999).
- Returns:
- An instance of
SerialDate
.
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.
- Returns:
- a instance of SerialDate.
public abstract int getDayOfMonth()
Returns the day of the month.
- Returns:
- the day of the month.
public abstract int getDayOfWeek()
Returns the day of the week.
- Returns:
- the day of the week.
public String getDescription()
Returns the description that is attached to the date. It is not required that a date have a description, but for some applications it is useful.
- Returns:
- The description (possibly
null
).
public SerialDate getEndOfCurrentMonth(SerialDate base)
Rolls the date forward to the last day of the month.
- Parameters:
base
- the base date.
- Returns:
- a new serial 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.
- Returns:
- the earliest date that falls on the specified day-of-the-week and is AFTER this 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.base
- the base date.
- Returns:
- the earliest date that falls on the specified day-of-the-week and is AFTER the base date.
public abstract int getMonth()
Returns the month (January = 1, February = 2, March = 3).
- Returns:
- the month of the year.
public static String[] getMonths()
Returns an array of month names.
- 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.
- Returns:
- an array of month names.
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.
- Returns:
- the nearest date that falls on the specified day-of-the-week.
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.base
- the base date.
- Returns:
- the date that falls on the specified day-of-the-week and is CLOSEST to 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.
- Returns:
- the latest date that falls on the specified day-of-the-week and is BEFORE this date.
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.base
- the base date.
- Returns:
- the latest date that falls on the specified day-of-the-week and is BEFORE the base date.
public abstract int getYYYY()
Returns the year (assume a valid range of 1900 to 9999).
- Returns:
- the year.
public abstract boolean isAfter(SerialDate other)
Returns true if this SerialDate represents the same date as the specified SerialDate.
- Parameters:
other
- the date being compared to.
- Returns:
true
if this SerialDate represents the same date as the specified SerialDate.
public abstract 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.
- Returns:
true
if this SerialDate represents an earlier date compared to the specified SerialDate.
public abstract boolean isInRange(SerialDate d1, SerialDate d2)
Returnstrue
if thisSerialDate
is within the specified range (INCLUSIVE). The date order of d1 and d2 is not important.
- Parameters:
d1
- a boundary date for the range.d2
- the other boundary date for the range.
- Returns:
- A boolean.
public abstract boolean isInRange(SerialDate d1, SerialDate d2, int include)
Returnstrue
if thisSerialDate
is within the specified range (caller specifies whether or not the end-points are included). The date order of d1 and d2 is not important.
- Parameters:
d1
- a boundary date for the range.d2
- the other boundary date for the range.include
- a code that controls whether or not the start and end dates are included in the range.
- Returns:
- A boolean.
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).
- Returns:
true
if the specified year is a leap year.
public abstract boolean isOn(SerialDate other)
Returns true if this SerialDate represents the same date as the specified SerialDate.
- Parameters:
other
- the date being compared to.
- Returns:
true
if this SerialDate represents the same date as the specified SerialDate.
public abstract boolean isOnOrAfter(SerialDate other)
Returns true if this SerialDate represents the same date as the specified SerialDate.
- Parameters:
other
- the date being compared to.
- Returns:
true
if this SerialDate represents the same date as the specified SerialDate.
public abstract boolean isOnOrBefore(SerialDate other)
Returns true if this SerialDate represents the same date as the specified SerialDate.
- Parameters:
other
- the date being compared to.
- Returns:
true
if this SerialDate represents the same date as the specified SerialDate.
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.
- Returns:
true
if the supplied integer code represents a valid month.
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.
- Returns:
true
if the supplied integer code represents a valid week-in-the-month.
public static boolean isValidWeekdayCode(int code)
Returnstrue
if the supplied integer code represents a valid day-of-the-week, andfalse
otherwise.
- Parameters:
code
- the code being checked for validity.
- Returns:
true
if the supplied integer code represents a valid day-of-the-week, andfalse
otherwise.
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.yyyy
- the year (in the range 1900 to 9999).
- Returns:
- the number of the last day of the month.
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).
- Returns:
- the number of leap years from 1900 to the specified year.
public static int monthCodeToQuarter(int code)
Returns the quarter for the specified month.
- Parameters:
code
- the month code (1-12).
- Returns:
- the quarter that the month belongs to.
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.
- Returns:
- a string representing the supplied 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.shortened
- iftrue
return the abbreviation of the month.
- Returns:
- a string representing the supplied 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'.
- Returns:
- a string representing the supplied 'relative'.
public void setDescription(String description)
Sets the description for the date.
- Parameters:
description
- the description for this date (null
permitted).
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. If the string is not recognised, this method returns -1.
- Parameters:
s
- the string to parse.
- Returns:
-1
if the string is not parseable, the month of the year otherwise.
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.
- Returns:
-1
if the string is not convertable, the day of the week otherwise.
public abstract java.util.Date toDate()
Returns a java.util.Date. Since java.util.Date has more precision than SerialDate, we need to define a convention for the 'time of day'.
- Returns:
- this as
java.util.Date
.
public abstract 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).
- Returns:
- the serial number for the date.
public String toString()
Converts the date to a string.
- Returns:
- a string representation of the date.
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.
- Returns:
- a string corresponding to the week-in-the-month code.
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.
- Returns:
- a string representing the supplied day-of-the-week.