|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectDate
public class Date
Objects of the Date class represent calendar dates such as March 14, 1997.
Class invariant: No Date object will ever represent an invalid date, such as one with a negative month or day, or one whose day exceeds the number of days in its month.
Constructor Summary | |
---|---|
Date()
Constructs a new object representing today's date. |
|
Date(int year,
int month,
int day)
Constructs a new object representing the given year, month, and day. |
Method Summary | |
---|---|
void |
addDays(int days)
Adds the given number of days to this Date. |
boolean |
equals(java.lang.Object o)
Returns whether o refers to a Date object representing the same year, month, and day as this one. |
int |
getDay()
Returns the day represented by this Date object. |
java.lang.String |
getDayOfWeek()
Returns a string such as "Monday" representing what day of the week this Date fell on. |
int |
getDaysInMonth()
Returns the number of days in the month represented by the current Date. |
int |
getMonth()
Returns the month represented by this Date object. |
int |
getYear()
Returns the year represented by this Date object. |
boolean |
isLeapYear()
Returns whether this Date falls on a leap year. |
void |
nextDay()
Advances this Date to the next day. |
void |
subtractWeeks(int weeks)
TODO: add this method |
java.lang.String |
toString()
Returns a String representation of this Date. |
Methods inherited from class java.lang.Object |
---|
getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Date(int year, int month, int day)
java.lang.IllegalArgumentException
- if month is not between 1 and 12, or if day is not between 1 and the number of days in that month.public Date()
Method Detail |
---|
public void addDays(int days)
java.lang.IllegalArgumentException
- if days < 0.public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int getDay()
public int getDaysInMonth()
public java.lang.String getDayOfWeek()
public int getMonth()
public int getYear()
public boolean isLeapYear()
public void nextDay()
public void subtractWeeks(int weeks)
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |