|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jfree.workbook.date.SerialDate | +--org.jfree.workbook.date.SpreadsheetDate
Represents a date using an integer, in a similar fashion to the implementation in Microsoft Excel. The range of dates supported is 1-Jan-1900 to 31-Dec-9999.
Be aware that there is a deliberate bug in Excel that recognises the year 1900 as a leap year when in fact it is not a leap year. You can find more information on the Microsoft website in article Q181370:
http://support.microsoft.com/support/kb/articles/Q181/3/70.asp
Excel uses the convention that 1-Jan-1900 = 1. This class uses the convention 1-Jan-1900 = 2. The result is that the day number in this class will be different to the Excel figure for January and February 1900...but then Excel adds in an extra day (29-Feb-1900 which does not actually exist!) and from that point forward the day numbers will match.
Field Summary |
Fields inherited from interface org.jfree.workbook.date.MonthConstants |
APRIL, AUGUST, DECEMBER, FEBRUARY, JANUARY, JULY, JUNE, MARCH, MAY, NOVEMBER, OCTOBER, SEPTEMBER |
Constructor Summary | |
SpreadsheetDate(int serial)
Standard constructor - creates a new date object representing the specified day number (which should be in the range 2 to 2958465. |
|
SpreadsheetDate(int day,
int month,
int year)
Constructs a new spreadsheet date. |
Method Summary | |
int |
compare(SerialDate other)
Returns the difference (in days) between this date and the specified 'other' date. |
boolean |
equals(java.lang.Object object)
Tests the equality of this SpreadsheetDate with an arbitrary Object. |
int |
getDayOfMonth()
Returns the day of the month. |
int |
getDayOfWeek()
Returns a code representing the day of the week. |
java.lang.String |
getDescription()
Returns the description that is attached to the date. |
int |
getMonth()
Returns the month (January = 1, February = 2, March = 3). |
int |
getYYYY()
Returns the year (assume a valid range of 1900 to 9999). |
boolean |
isAfter(SerialDate other)
Returns true if this SerialDate represents the same date as the specified SerialDate. |
boolean |
isBefore(SerialDate other)
Returns true if this SerialDate represents an earlier date compared to the specified SerialDate. |
boolean |
isInRange(SerialDate d1,
SerialDate d2)
Returns true if this SerialDate is within the specified range (INCLUSIVE). |
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). |
boolean |
isOn(SerialDate other)
Returns true if this SerialDate represents the same date as the specified SerialDate. |
boolean |
isOnOrAfter(SerialDate other)
Returns true if this SerialDate represents the same date as the specified SerialDate. |
boolean |
isOnOrBefore(SerialDate other)
Returns true if this SerialDate represents the same date as the specified SerialDate. |
void |
setDescription(java.lang.String description)
Sets the description for the date. |
java.util.Date |
toDate()
Returns a java.util.Date equivalent to this date. |
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). |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public SpreadsheetDate(int day, int month, int year)
day
- the day.month
- the month (1-12).year
- the year (in the range 1900 to 9999).public SpreadsheetDate(int serial)
serial
- the serial number for the day (range: 2 to 2958465).Method Detail |
public java.lang.String getDescription()
It is not required that a date have a description, but for some applications it is useful.
getDescription
in class SerialDate
public void setDescription(java.lang.String description)
setDescription
in class SerialDate
description
- the description for this date.public int toSerial()
toSerial
in class SerialDate
public java.util.Date toDate()
toDate
in class SerialDate
java.util.Date
.public int getYYYY()
getYYYY
in class SerialDate
public int getMonth()
getMonth
in class SerialDate
public int getDayOfMonth()
getDayOfMonth
in class SerialDate
public int getDayOfWeek()
The codes are defined in the SerialDate class as: SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, and SATURDAY.
getDayOfWeek
in class SerialDate
public boolean equals(java.lang.Object object)
This method will return true ONLY if the object is an instance of the SerialDate base class, and it represents the same day as this SpreadsheetDate.
equals
in class java.lang.Object
object
- the object to compare.
true
if this is equal to object.public int compare(SerialDate other)
compare
in class SerialDate
other
- the date being compared to.
public boolean isOn(SerialDate other)
isOn
in class SerialDate
other
- the date being compared to.
true
if this SerialDate represents the same date as the
specified SerialDate.public boolean isBefore(SerialDate other)
isBefore
in class SerialDate
other
- the date being compared to.
true
if this SerialDate represents an earlier date
compared to the specified SerialDate.public boolean isOnOrBefore(SerialDate other)
isOnOrBefore
in class SerialDate
other
- the date being compared to.
true
if this SerialDate represents the same date
as the specified SerialDate.public boolean isAfter(SerialDate other)
isAfter
in class SerialDate
other
- the date being compared to.
true
if this SerialDate represents the same date
as the specified SerialDate.public boolean isOnOrAfter(SerialDate other)
isOnOrAfter
in class SerialDate
other
- the date being compared to.
true
if this SerialDate represents the same date as
the specified SerialDate.public boolean isInRange(SerialDate d1, SerialDate d2)
isInRange
in class SerialDate
d1
- one boundary date for the range.d2
- a second boundary date for the range.
true
if this SerialDate is within the specified range.public boolean isInRange(SerialDate d1, SerialDate d2, int include)
isInRange
in class SerialDate
d1
- one boundary date for the range.d2
- a second boundary date for the range.include
- if true
include d2 in the search.
true
if this SerialDate is within the specified range.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |