|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface DayDate
Represents a date - year, month, day in the range Jan 1, 1000 - Dec 31, 9999, with a lot of utilities.
The framework is aware of leap years, and checks all dates for validity.
Date objects are always immutable - they cannot be changed once created.
The natural order of this class orders instances in chronological order, and two instances are considered equal if they represent the same year, month and day.
Example usage
Create new instances: |
DayDate.factory.now() DayDate.factory.getDefault() DayDate.factory.parse(...)
|
Formatting: |
DayDate.iso().formatXXX() DayDate.eur().formatXXX() DayDate.us().formatXXX()
|
Serializing |
DayDate.serialize() DayDate.factory.deserialize()
|
Field Summary | |
---|---|
static DayDateFactory |
factory
A default implementaton of DayDateFactory , for creating new
instances. |
Method Summary | |
---|---|
int |
day()
|
boolean |
equals(Object other)
|
DayDateFormatter |
eur()
Provides a formatter for this date instance that formats day dates according to some de-facto European standard. |
DayOfWeek |
getDayOfWeek()
Calculates the day of week of this date. |
int |
hashCode()
|
boolean |
isLaterMonthThan(DayDate date)
Determines whether this is in a later month than the given date. |
boolean |
isLaterYearThan(DayDate date)
Determines whether this is in a later year than the given date. |
DayDateFormatter |
iso()
Provides a formatter for this date instance that formats day dates according to the ISO-8601 standard. |
boolean |
isSameMonthAs(DayDate date)
Determines whether this is in the same month and the same year as the given date. |
boolean |
isSameYearAs(DayDate date)
Determines whether this is in the same year as the given date. |
Month |
month()
|
DayDate |
plusDays(int offset)
Adds or subtracts the given number of days to this date. |
DayDate |
plusMonths(int offset)
Adds or subtracts the given number of months to this date. |
DayDate |
plusYears(int offset)
Adds or subtracts the given number of years to this date. |
String |
serialize()
|
int |
toInt()
Creates an int representation of the date, which when written in base 10 is the string YYYYMMDD . |
String |
toString()
Overrides Object.toString() . |
DayDateFormatter |
us()
Provides a formatter for this date instance that formats day dates according to the US standard. |
int |
year()
|
Methods inherited from interface java.lang.Comparable |
---|
compareTo |
Field Detail |
---|
static final DayDateFactory factory
DayDateFactory
, for creating new
instances. The factory will create serializable
instances.
Method Detail |
---|
int year()
Month month()
month
represented by this date.int day()
DayOfWeek getDayOfWeek()
DayDate plusYears(int offset)
In the rare case that this is Feb 29 on a leap year, and adding the given offset results in a non leap year, the date will be set to Feb 28.
offset
- The offset in years. Can be positive, zero or negative.
IllegalArgumentException
- If the resulting date is out of range.DayDate plusMonths(int offset)
If adding the given number of months would make the day of month over the new month's maximum it will be reduced to the proper maximum. Hence, adding three months to 2011-05-31 will give 2011-08-31, but adding four will give 2011-09-30. And adding 13 months to 2010-01-30 will give the date 2011-02-28.
offset
- The offset in months. Can be positive, zero or negative.
IllegalArgumentException
- If the resulting date is out of range.DayDate plusDays(int offset)
offset
- The offset in days. Can be positive, zero or negative.
IllegalArgumentException
- If the resulting date is out of range.boolean isLaterYearThan(DayDate date)
date
- The date to compare to.
boolean isSameYearAs(DayDate date)
date
- The date to compare to.
boolean isLaterMonthThan(DayDate date)
date
- The date to compare to.
boolean isSameMonthAs(DayDate date)
date
- The date to compare to.
int hashCode()
hashCode
in class Object
boolean equals(Object other)
equals
in class Object
DayDateFormatter iso()
YYYY-MM-DD
and YYYYMMDD
.
DayDateFormatter eur()
DD.MM.YYYY
and DDMMYYYY
.
DayDateFormatter us()
MM/DD/YYYY
and MMDDYYYY
.
String serialize()
YYYYMMDD
.String toString()
Object.toString()
.
toString
in class Object
YYYY-MM-DD
int toInt()
YYYYMMDD
. E.g, the date 2011-03-02 is
represented as the integer 20110302.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |