corejava
Class Day

java.lang.Object
  |
  +--corejava.Day
All Implemented Interfaces:
java.lang.Cloneable

public class Day
extends java.lang.Object
implements java.lang.Cloneable


Constructor Summary
Day()
          Constructs today's date
Day(int yyyy, int m, int d)
          Constructs a specific date
 
Method Summary
 void advance(int n)
          Advances this day by n days.
 java.lang.Object clone()
          Makes a bitwise copy of a Day object
 int daysBetween(Day b)
          The number of days between this and day parameter
 int getDay()
           
 int getMonth()
           
 int getYear()
           
 java.lang.String toString()
          A string representation of the day
 int weekday()
          Gets the weekday
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Day

public Day()
Constructs today's date

Day

public Day(int yyyy,
           int m,
           int d)
Constructs a specific date
Parameters:
yyyy - year (full year, e.g., 1996, not starting from 1900)
m - month
d - day
Throws:
java.lang.IllegalArgumentException - if yyyy m d not a valid date
Method Detail

advance

public void advance(int n)
Advances this day by n days. For example. d.advance(30) adds thirdy days to d
Parameters:
n - the number of days by which to change this day (can be < 0)

getDay

public int getDay()

getMonth

public int getMonth()

getYear

public int getYear()

weekday

public int weekday()
Gets the weekday
Returns:
the weekday (0 = Sunday, 1 = Monday, ..., 6 = Saturday)

daysBetween

public int daysBetween(Day b)
The number of days between this and day parameter
Parameters:
b - any date
Returns:
the number of days between this and day parameter and b (> 0 if this day comes after b)

toString

public java.lang.String toString()
A string representation of the day
Overrides:
toString in class java.lang.Object
Returns:
a string representation of the day

clone

public java.lang.Object clone()
Makes a bitwise copy of a Day object
Overrides:
clone in class java.lang.Object
Returns:
a bitwise copy of a Day object