public class Date extends Object implements Comparable<Date>
For additional documentation, see Section 1.2 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.
| Constructor and Description |
|---|
Date(int month,
int day,
int year)
Initializes a new date from the month, day, and year.
|
Date(String date)
Initializes new date specified as a string in form MM/DD/YYYY.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(Date that)
Compare this date to that date.
|
int |
day()
Return the day.
|
boolean |
equals(Object x)
Is this date equal to x?
|
int |
hashCode()
Return a hash code.
|
boolean |
isAfter(Date b)
Is this date after b?
|
boolean |
isBefore(Date b)
Is this date before b?
|
static void |
main(String[] args)
Unit tests the date data type.
|
int |
month()
Return the month.
|
Date |
next()
Returns the next date in the calendar.
|
String |
toString()
Return a string representation of this date.
|
int |
year()
Return the year.
|
public Date(int month,
int day,
int year)
month - the month (between 1 and 12)day - the day (between 1 and 28-31, depending on the month)year - the yearIllegalArgumentException - if the date is invalidpublic Date(String date)
date - the string representation of the dateIllegalArgumentException - if the date is invalidpublic int month()
public int day()
public int year()
public Date next()
public boolean isAfter(Date b)
public boolean isBefore(Date b)
public int compareTo(Date that)
compareTo in interface Comparable<Date>public String toString()
public boolean equals(Object x)
public int hashCode()
public static void main(String[] args)
Copyright © 2014. All Rights Reserved.