|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.pentaho.reporting.engine.classic.core.modules.gui.base.date.SerialDate
public abstract class SerialDate
An abstract class that defines our requirements for manipulating dates, without tying down a particular implementation.
Requirement 1 : match at least what Excel does for dates; Requirement 2 : the date represented by the class is immutable;
Why not just use java.util.Date? We will, when it makes sense. At times, java.util.Date can be *too* precise - it represents an instant in time, accurate to 1/1000th of a second (with the date itself depending on the time-zone). Sometimes we just want to represent a particular day (e.g. 21 January 2015) without concerning ourselves about the time of day, or the time-zone, or anything else. That's what we've defined SerialDate for.
You can call getInstance() to get a concrete subclass of SerialDate, without worrying about the exact implementation.
Field Summary | |
---|---|
static DateFormatSymbols |
DATE_FORMAT_SYMBOLS
Deprecated. Date format symbols. |
static int |
FIRST_WEEK_IN_MONTH
Deprecated. A useful constant for referring to the first week in a month. |
static int |
FOLLOWING
Deprecated. Useful constant for specifying a day of the week relative to a fixed date. |
static int |
FOURTH_WEEK_IN_MONTH
Deprecated. A useful constant for referring to the fourth week in a month. |
static int |
FRIDAY
Deprecated. Useful constant for Friday. |
static int |
INCLUDE_BOTH
Deprecated. Useful range constant. |
static int |
INCLUDE_FIRST
Deprecated. Useful range constant. |
static int |
INCLUDE_NONE
Deprecated. Useful range constant. |
static int |
INCLUDE_SECOND
Deprecated. Useful range constant. |
static int |
LAST_WEEK_IN_MONTH
Deprecated. A useful constant for referring to the last week in a month. |
static int |
MAXIMUM_YEAR_SUPPORTED
Deprecated. The highest year value supported by this date format. |
static int |
MINIMUM_YEAR_SUPPORTED
Deprecated. The lowest year value supported by this date format. |
static int |
MONDAY
Deprecated. Useful constant for Monday. |
static int |
NEAREST
Deprecated. Useful constant for specifying a day of the week relative to a fixed date. |
static int |
PRECEDING
Deprecated. Useful constant for specifying a day of the week relative to a fixed date. |
static int |
SATURDAY
Deprecated. Useful constant for Saturday. |
static int |
SECOND_WEEK_IN_MONTH
Deprecated. A useful constant for referring to the second week in a month. |
static int |
SERIAL_LOWER_BOUND
Deprecated. The serial number for 1 January 1900. |
static int |
SERIAL_UPPER_BOUND
Deprecated. The serial number for 31 December 9999. |
static int |
SUNDAY
Deprecated. Useful constant for Sunday. |
static int |
THIRD_WEEK_IN_MONTH
Deprecated. A useful constant for referring to the third week in a month. |
static int |
THURSDAY
Deprecated. Useful constant for Thrusday. |
static int |
TUESDAY
Deprecated. Useful constant for Tuesday. |
static int |
WEDNESDAY
Deprecated. Useful constant for Wednesday. |
Method Summary | |
---|---|
static SerialDate |
addDays(int days,
SerialDate base)
Deprecated. Creates a new date by adding the specified number of days to the base date. |
static SerialDate |
addMonths(int months,
SerialDate base)
Deprecated. Creates a new date by adding the specified number of months to the base date. |
static SerialDate |
addYears(int years,
SerialDate base)
Deprecated. Creates a new date by adding the specified number of years to the base date. |
abstract int |
compare(SerialDate other)
Deprecated. Returns the difference (in days) between this date and the specified 'other' date. |
static SerialDate |
createInstance(Date date)
Deprecated. Factory method that returns an instance of a subclass of SerialDate. |
static SerialDate |
createInstance(int serial)
Deprecated. Factory method that returns an instance of some concrete subclass of SerialDate . |
static SerialDate |
createInstance(int day,
int month,
int yyyy)
Deprecated. Factory method that returns an instance of some concrete subclass of SerialDate . |
abstract int |
getDayOfMonth()
Deprecated. Returns the day of the month. |
abstract int |
getDayOfWeek()
Deprecated. Returns the day of the week. |
String |
getDescription()
Deprecated. Returns the description that is attached to the date. |
SerialDate |
getEndOfCurrentMonth(SerialDate base)
Deprecated. Rolls the date forward to the last day of the month. |
SerialDate |
getFollowingDayOfWeek(int targetDOW)
Deprecated. Returns the earliest date that falls on the specified day-of-the-week and is AFTER this date. |
static SerialDate |
getFollowingDayOfWeek(int targetWeekday,
SerialDate base)
Deprecated. Returns the earliest date that falls on the specified day-of-the-week and is AFTER the base date. |
abstract int |
getMonth()
Deprecated. Returns the month (January = 1, February = 2, March = 3). |
static String[] |
getMonths()
Deprecated. Returns an array of month names. |
static String[] |
getMonths(boolean shortened)
Deprecated. Returns an array of month names. |
SerialDate |
getNearestDayOfWeek(int targetDOW)
Deprecated. Returns the nearest date that falls on the specified day-of-the-week. |
static SerialDate |
getNearestDayOfWeek(int targetDOW,
SerialDate base)
Deprecated. Returns the date that falls on the specified day-of-the-week and is CLOSEST to the base date. |
SerialDate |
getPreviousDayOfWeek(int targetDOW)
Deprecated. Returns the latest date that falls on the specified day-of-the-week and is BEFORE this date. |
static SerialDate |
getPreviousDayOfWeek(int targetWeekday,
SerialDate base)
Deprecated. Returns the latest date that falls on the specified day-of-the-week and is BEFORE the base date. |
abstract int |
getYYYY()
Deprecated. Returns the year (assume a valid range of 1900 to 9999). |
abstract boolean |
isAfter(SerialDate other)
Deprecated. Returns true if this SerialDate represents the same date as the specified SerialDate. |
abstract boolean |
isBefore(SerialDate other)
Deprecated. Returns true if this SerialDate represents an earlier date compared to the specified SerialDate. |
abstract boolean |
isInRange(SerialDate d1,
SerialDate d2)
Deprecated. Returns true if this SerialDate is within the
specified range (INCLUSIVE). |
abstract boolean |
isInRange(SerialDate d1,
SerialDate d2,
int include)
Deprecated. Returns true if this SerialDate is within the
specified range (caller specifies whether or not the end-points are
included). |
static boolean |
isLeapYear(int yyyy)
Deprecated. Determines whether or not the specified year is a leap year. |
abstract boolean |
isOn(SerialDate other)
Deprecated. Returns true if this SerialDate represents the same date as the specified SerialDate. |
abstract boolean |
isOnOrAfter(SerialDate other)
Deprecated. Returns true if this SerialDate represents the same date as the specified SerialDate. |
abstract boolean |
isOnOrBefore(SerialDate other)
Deprecated. Returns true if this SerialDate represents the same date as the specified SerialDate. |
static boolean |
isValidMonthCode(int code)
Deprecated. Returns true if the supplied integer code represents a valid month. |
static boolean |
isValidWeekdayCode(int code)
Deprecated. Returns true if the supplied integer code represents a
valid day-of-the-week, and false otherwise. |
static boolean |
isValidWeekInMonthCode(int code)
Deprecated. Returns true if the supplied integer code represents a valid week-in-the-month, and false otherwise. |
static int |
lastDayOfMonth(int month,
int yyyy)
Deprecated. Returns the number of the last day of the month, taking into account leap years. |
static int |
leapYearCount(int yyyy)
Deprecated. Returns the number of leap years from 1900 to the specified year INCLUSIVE. |
static int |
monthCodeToQuarter(int code)
Deprecated. Returns the quarter for the specified month. |
static String |
monthCodeToString(int month)
Deprecated. Returns a string representing the supplied month. |
static String |
monthCodeToString(int month,
boolean shortened)
Deprecated. Returns a string representing the supplied month. |
void |
setDescription(String description)
Deprecated. Sets the description for the date. |
static int |
stringToMonthCode(String s)
Deprecated. Converts a string to a month code. |
abstract Date |
toDate()
Deprecated. Returns a java.util.Date. |
abstract int |
toSerial()
Deprecated. 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). |
String |
toString()
Deprecated. Converts the date to a string. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.lang.Comparable |
---|
compareTo |
Field Detail |
---|
public static final DateFormatSymbols DATE_FORMAT_SYMBOLS
public static final int SERIAL_LOWER_BOUND
public static final int SERIAL_UPPER_BOUND
public static final int MINIMUM_YEAR_SUPPORTED
public static final int MAXIMUM_YEAR_SUPPORTED
public static final int MONDAY
public static final int TUESDAY
public static final int WEDNESDAY
public static final int THURSDAY
public static final int FRIDAY
public static final int SATURDAY
public static final int SUNDAY
public static final int FIRST_WEEK_IN_MONTH
public static final int SECOND_WEEK_IN_MONTH
public static final int THIRD_WEEK_IN_MONTH
public static final int FOURTH_WEEK_IN_MONTH
public static final int LAST_WEEK_IN_MONTH
public static final int INCLUDE_NONE
public static final int INCLUDE_FIRST
public static final int INCLUDE_SECOND
public static final int INCLUDE_BOTH
public static final int PRECEDING
public static final int NEAREST
public static final int FOLLOWING
Method Detail |
---|
public static boolean isValidWeekdayCode(int code)
true
if the supplied integer code represents a
valid day-of-the-week, and false
otherwise.
code
- the code being checked for validity.
true
if the supplied integer code represents a
valid day-of-the-week, and false
otherwise.public static String[] getMonths()
public static String[] getMonths(boolean shortened)
shortened
- a flag indicating that shortened month names should
be returned.
public static boolean isValidMonthCode(int code)
code
- the code being checked for validity.
true
if the supplied integer code represents a
valid month.public static int monthCodeToQuarter(int code)
code
- the month code (1-12).
public static String monthCodeToString(int month)
The string returned is the long form of the month name taken from the default locale.
month
- the month.
public static String monthCodeToString(int month, boolean shortened)
The string returned is the long or short form of the month name taken from the default locale.
month
- the month.shortened
- if true
return the abbreviation of the
month.
public static int stringToMonthCode(String s)
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.
s
- the string to parse.
-1
if the string is not parseable, the month of the
year otherwise.public static boolean isValidWeekInMonthCode(int code)
code
- the code being checked for validity.
true
if the supplied integer code represents a
valid week-in-the-month.public static boolean isLeapYear(int yyyy)
yyyy
- the year (in the range 1900 to 9999).
true
if the specified year is a leap year.public static int leapYearCount(int yyyy)
Note that 1900 is not a leap year.
yyyy
- the year (in the range 1900 to 9999).
public static int lastDayOfMonth(int month, int yyyy)
month
- the month.yyyy
- the year (in the range 1900 to 9999).
public static SerialDate addDays(int days, SerialDate base)
days
- the number of days to add (can be negative).base
- the base date.
public static SerialDate addMonths(int months, SerialDate base)
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.
months
- the number of months to add (can be negative).base
- the base date.
public static SerialDate addYears(int years, SerialDate base)
years
- the number of years to add (can be negative).base
- the base date.
public static SerialDate getPreviousDayOfWeek(int targetWeekday, SerialDate base)
targetWeekday
- a code for the target day-of-the-week.base
- the base date.
public static SerialDate getFollowingDayOfWeek(int targetWeekday, SerialDate base)
targetWeekday
- a code for the target day-of-the-week.base
- the base date.
public static SerialDate getNearestDayOfWeek(int targetDOW, SerialDate base)
targetDOW
- a code for the target day-of-the-week.base
- the base date.
public SerialDate getEndOfCurrentMonth(SerialDate base)
base
- the base date.
public static SerialDate createInstance(int day, int month, int yyyy)
SerialDate
.
day
- the day (1-31).month
- the month (1-12).yyyy
- the year (in the range 1900 to 9999).
SerialDate
.public static SerialDate createInstance(int serial)
SerialDate
.
serial
- the serial number for the day (1 January 1900 = 2).
public static SerialDate createInstance(Date date)
date
- A Java date object.
public abstract int toSerial()
public abstract Date toDate()
java.util.Date
.public String getDescription()
null
).public void setDescription(String description)
description
- the description for this date (null
permitted).public String toString()
toString
in class Object
public abstract int getYYYY()
public abstract int getMonth()
public abstract int getDayOfMonth()
public abstract int getDayOfWeek()
public abstract int compare(SerialDate other)
The result is positive if this date is after the 'other' date and negative if it is before the 'other' date.
other
- the date being compared to.
public abstract boolean isOn(SerialDate other)
other
- the date being compared to.
true
if this SerialDate represents the same date as
the specified SerialDate.public abstract boolean isBefore(SerialDate other)
other
- The date being compared to.
true
if this SerialDate represents an earlier date
compared to the specified SerialDate.public abstract boolean isOnOrBefore(SerialDate other)
other
- the date being compared to.
true if this SerialDate represents the same date
as the specified SerialDate.
public abstract boolean isAfter(SerialDate other)
other
- the date being compared to.
true
if this SerialDate represents the same date
as the specified SerialDate.public abstract boolean isOnOrAfter(SerialDate other)
other
- the date being compared to.
true
if this SerialDate represents the same date
as the specified SerialDate.public abstract boolean isInRange(SerialDate d1, SerialDate d2)
true
if this SerialDate
is within the
specified range (INCLUSIVE). The date order of d1 and d2 is not
important.
d1
- a boundary date for the range.d2
- the other boundary date for the range.
public abstract boolean isInRange(SerialDate d1, SerialDate d2, int include)
true
if this SerialDate
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.
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.
public SerialDate getPreviousDayOfWeek(int targetDOW)
targetDOW
- a code for the target day-of-the-week.
public SerialDate getFollowingDayOfWeek(int targetDOW)
targetDOW
- a code for the target day-of-the-week.
public SerialDate getNearestDayOfWeek(int targetDOW)
targetDOW
- a code for the target day-of-the-week.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |