com.jrefinery.date
Class DayOfWeekInMonthRule

java.lang.Object
  extended by com.jrefinery.date.AnnualDateRule
      extended by com.jrefinery.date.DayOfWeekInMonthRule
All Implemented Interfaces:
java.lang.Cloneable

public class DayOfWeekInMonthRule
extends AnnualDateRule
implements java.lang.Cloneable

An annual date rule that specifies the nth day of the week in a given month (e.g. the third Wednesday in June, or the last Friday in November).


Field Summary
protected  int count
          FIRST, SECOND, THIRD, FOURTH or LAST.
protected  int dayOfWeek
          The day of the week (SerialDate.MONDAY, SerialDate.TUESDAY...).
protected  int month
          The month (1 to 12, or SerialDate.JANUARY, SerialDate.FEBRUARY...).
 
Constructor Summary
DayOfWeekInMonthRule()
          Default constructor: builds a rule for the first Monday in January by default.
DayOfWeekInMonthRule(int count, int dayOfWeek, int month)
          Standard constructor: builds a rule with the specified attributes.
 
Method Summary
 int getCount()
          Returns the 'count' for this rule (one of FIRST, SECOND, THIRD, FOURTH and LAST).
 SerialDate getDate(int year)
          Return the date for this rule, given the year.
 int getDayOfWeek()
          Returns the day-of-the-week for this rule (SerialDate.MONDAY, SerialDate.TUESDAY, etc.).
 int getMonth()
          Returns the month for this rule.
 void setCount(int count)
          Sets the 'count' for this rule (one of FIRST, SECOND, THIRD, FOURTH and LAST).
 void setDayOfWeek(int dayOfWeek)
          Sets the day-of-the-week for this rule.
 void setMonth(int month)
          Sets the month for this rule.
 
Methods inherited from class com.jrefinery.date.AnnualDateRule
clone
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

count

protected int count
FIRST, SECOND, THIRD, FOURTH or LAST.


dayOfWeek

protected int dayOfWeek
The day of the week (SerialDate.MONDAY, SerialDate.TUESDAY...).


month

protected int month
The month (1 to 12, or SerialDate.JANUARY, SerialDate.FEBRUARY...).

Constructor Detail

DayOfWeekInMonthRule

public DayOfWeekInMonthRule()
Default constructor: builds a rule for the first Monday in January by default.


DayOfWeekInMonthRule

public DayOfWeekInMonthRule(int count,
                            int dayOfWeek,
                            int month)
Standard constructor: builds a rule with the specified attributes.

Parameters:
count - One of: FIRST, SECOND, THIRD, FOURTH or LAST.
dayOfWeek - The day-of-the-week (SerialDate.MONDAY, SerialDate.TUESDAY, etc.).
month - The month (SerialDate.JANUARY, SerialDate.FEBRUARY, etc.).
Method Detail

getCount

public int getCount()
Returns the 'count' for this rule (one of FIRST, SECOND, THIRD, FOURTH and LAST).

Returns:
The 'count'.

setCount

public void setCount(int count)
Sets the 'count' for this rule (one of FIRST, SECOND, THIRD, FOURTH and LAST).

Parameters:
count - The 'count'.

getDayOfWeek

public int getDayOfWeek()
Returns the day-of-the-week for this rule (SerialDate.MONDAY, SerialDate.TUESDAY, etc.).

Returns:
The day-of-the-week.

setDayOfWeek

public void setDayOfWeek(int dayOfWeek)
Sets the day-of-the-week for this rule.

Parameters:
dayOfWeek - The day-of-the-week.

getMonth

public int getMonth()
Returns the month for this rule.

Returns:
The month.

setMonth

public void setMonth(int month)
Sets the month for this rule.

Parameters:
month - The month (SerialDate.JANUARY, SerialDate.FEBRUARY, etc.).

getDate

public SerialDate getDate(int year)
Return the date for this rule, given the year.

Specified by:
getDate in class AnnualDateRule
Parameters:
year - The year.
Returns:
The date generated by the rule for the given year.


Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.