rsvp.model
Class SimpleDate

java.lang.Object
  extended by rsvp.model.SimpleDate
All Implemented Interfaces:
java.io.Serializable

public class SimpleDate
extends java.lang.Object
implements java.io.Serializable

SimpleDate is a very simple representation of a calendar date and time. Notably, it only represents dates in the Gregorian calendar system (with American English month names) and does not account for separate time zones. However, it does validate that the date and time it stores are actually possible, given the Gregorian calendar and a 24-hour clock. (It will, however, be inaccurate for dates from before the introduction of the Gregorian calendar.)

Author:
willb
See Also:
Serialized Form

Field Summary
static long serialVersionUID
           
 
Constructor Summary
SimpleDate(int month, int day, int year, int hour, int minute)
          Constructs a SimpleDate with the given time values.
 
Method Summary
 java.lang.String dateToString()
          Returns a string representation of the date.
 int getDay()
           
 int getHour()
           
 int getMinute()
           
 int getMonth()
           
 int getYear()
           
 boolean isValid()
          Returns true if this SimpleDate is valid -- that is, does this SimpleDate correspond to a legitimate date in the Gregorian calendar? -- and false otherwise.
 void setDay(int day)
           
 void setHour(int hour)
           
 void setMinute(int minute)
           
 void setMonth(int month)
           
 void setYear(int year)
           
 java.lang.String timeToString()
          Returns a string representation of the time.
 java.lang.String toString()
          Returns a string representation of the date and time.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

SimpleDate

public SimpleDate(int month,
                  int day,
                  int year,
                  int hour,
                  int minute)
Constructs a SimpleDate with the given time values. Does not check validity of the described SimpleDate.

Parameters:
month - a month, between 1 and 12, inclusive
day - a day number, between 1 and the number of days in the given month and year
year - a year number
hour - an hour, between 0 and 23
minute - a minute, between 0 and 59
Method Detail

isValid

public boolean isValid()
Returns true if this SimpleDate is valid -- that is, does this SimpleDate correspond to a legitimate date in the Gregorian calendar? -- and false otherwise. A SimpleDate is valid if the hour is between 0 and 23, the minute is between 0 and 59, the month is between 1 and 12, and the day is between 1 and the number of days in the given month and year, inclusive. (Note that 12:00 on 2/29/2007 is invalid, while 12:00 on 2/29/2000 would be.)

Returns:
true if and only if this SimpleDate is valid.

getDay

public int getDay()

getHour

public int getHour()

getMinute

public int getMinute()

getMonth

public int getMonth()

getYear

public int getYear()

setDay

public void setDay(int day)

setHour

public void setHour(int hour)

setMinute

public void setMinute(int minute)

setMonth

public void setMonth(int month)

setYear

public void setYear(int year)

timeToString

public java.lang.String timeToString()
Returns a string representation of the time.

Returns:
a string representation of the time.

dateToString

public java.lang.String dateToString()
Returns a string representation of the date.

Returns:
a string representation of the date.

toString

public java.lang.String toString()
Returns a string representation of the date and time.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of the date and time.