com.prozima.time
Class DayAndYear

java.lang.Object
  extended by com.prozima.time.DayAndYear
All Implemented Interfaces:
java.lang.Comparable<DayAndYear>

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

Represents a specific day in time by specifying a specific year and the day of this year. Class has no concept of hourly time or timezone. Its an immutable class, therefore instances of the class cannot be changed after their construction.


Constructor Summary
DayAndYear(java.util.Date inDate)
          Create a new instance of a DayAndYear, specifying the day using Date.
DayAndYear(int inYear, int inDayOfYear)
          Create a new instance of a DayAndYear, specifying the year and day individually.
 
Method Summary
 boolean after(DayAndYear inOther)
          Compare this day and year against another specified day and year to check if the this day/year is after that specified by inOther.
 boolean before(DayAndYear inOther)
          Compare this day and year against another specified day and year to check if the this day/year is before that specified by inOther.
 int compareTo(DayAndYear inOther)
           
 boolean equals(java.lang.Object inObject)
           
 int getDayOfYear()
          Get the day of the year represented by this DayAndYear.
 int getYear()
          Get the Year represented by this DayAndYear.
 int hashCode()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DayAndYear

public DayAndYear(java.util.Date inDate)
Create a new instance of a DayAndYear, specifying the day using Date.

Parameters:
inDate - A specific date. The time part of the date is ignored. Cannot be null.

DayAndYear

public DayAndYear(int inYear,
                  int inDayOfYear)
Create a new instance of a DayAndYear, specifying the year and day individually.

Parameters:
inYear - Integer representing the year e.g. 2004, 2010, 1977 etc..
inDayOfYear - Index of the day of the year. 1st of January is 1.
Method Detail

after

public boolean after(DayAndYear inOther)
Compare this day and year against another specified day and year to check if the this day/year is after that specified by inOther.

Parameters:
inOther - A different day and year.
Returns:
true if this day/year is after inOther's day/year.
Throws:
java.lang.IllegalArgumentException - is thrown if inOther is null.

before

public boolean before(DayAndYear inOther)
Compare this day and year against another specified day and year to check if the this day/year is before that specified by inOther.

Parameters:
inOther - A different day and year.
Returns:
true if this day/year is before inOther's day/year.
Throws:
java.lang.IllegalArgumentException - is thrown if inOther is null.

compareTo

public int compareTo(DayAndYear inOther)
Specified by:
compareTo in interface java.lang.Comparable<DayAndYear>

equals

public boolean equals(java.lang.Object inObject)
Overrides:
equals in class java.lang.Object

getDayOfYear

public int getDayOfYear()
Get the day of the year represented by this DayAndYear.

Returns:
the dayOfYear

getYear

public int getYear()
Get the Year represented by this DayAndYear.

Returns:
the year

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object