Class EasyDate

java.lang.Object
  extended by EasyDate
All Implemented Interfaces:
java.lang.Comparable<EasyDate>

public class EasyDate
extends java.lang.Object
implements java.lang.Comparable<EasyDate>


Field Summary
static long MILLIS_DAY
          Number of milliseconds in 24 hours.
 
Constructor Summary
EasyDate()
          Constructs a date for the current month, day, and year.
EasyDate(EasyDate other)
          Constructs a date equal to a given date.
EasyDate(int month, int day, int year)
          Constructs a date for given month, day, and year.
 
Method Summary
 EasyDate add(int numDays)
          Returns a new EasyDate that is numDays later than this date (or earlier, if numDays is negative).
 int compareTo(EasyDate other)
          Compares this date to other.
 int daysTo(EasyDate other)
          Returns the number of days from this date to other.
 boolean equals(java.lang.Object obj)
          Checks whether this date id equal to other.
 int getDay()
          Returns the day of this EasyDate.
 int getMonth()
          Returns the month of this EasyDate.
 int getYear()
          Returns the year of this EasyDate.
static boolean isLeapYear(int year)
          Checks whether a given year is a leap year.
 java.lang.String toString()
          Returns this date as a string in the mm/dd/yyyy format.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MILLIS_DAY

public static final long MILLIS_DAY
Number of milliseconds in 24 hours.

See Also:
Constant Field Values
Constructor Detail

EasyDate

public EasyDate()
Constructs a date for the current month, day, and year.


EasyDate

public EasyDate(int month,
                int day,
                int year)
Constructs a date for given month, day, and year.

Parameters:
month - the month (1 - 12)
day - the day (1 - 31)
year - the year (1600 - 2100)

EasyDate

public EasyDate(EasyDate other)
Constructs a date equal to a given date.

Parameters:
other - the date to be copied.
Method Detail

isLeapYear

public static boolean isLeapYear(int year)
Checks whether a given year is a leap year.

Parameters:
year - a year to be checked (1600-2100).
Returns:
true if year is a leap year, false otherwise.

getMonth

public int getMonth()
Returns the month of this EasyDate.


getDay

public int getDay()
Returns the day of this EasyDate.


getYear

public int getYear()
Returns the year of this EasyDate.


add

public EasyDate add(int numDays)
Returns a new EasyDate that is numDays later than this date (or earlier, if numDays is negative).


daysTo

public int daysTo(EasyDate other)
Returns the number of days from this date to other.


compareTo

public int compareTo(EasyDate other)
Compares this date to other.

Specified by:
compareTo in interface java.lang.Comparable<EasyDate>
Returns:
a positive integer (the number of days elapsed) if this date is later than other; returns a negative integer if this date is earlier than other; returns 0 if this date is the same as other.

equals

public boolean equals(java.lang.Object obj)
Checks whether this date id equal to other.

Overrides:
equals in class java.lang.Object
Returns:
true if obj represents the same date as this, false otherwise.

toString

public java.lang.String toString()
Returns this date as a string in the mm/dd/yyyy format.

Overrides:
toString in class java.lang.Object