org.sandev.TaskHeap.HeapCalculator
Class ElapsedTimeCalendar

java.lang.Object
  extended by java.util.Calendar
      extended by java.util.GregorianCalendar
          extended by org.sandev.TaskHeap.HeapCalculator.ElapsedTimeCalendar
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<java.util.Calendar>

public class ElapsedTimeCalendar
extends java.util.GregorianCalendar

An elapsed time accumulator that keeps track of what calendar day you are at as you add up work hours. This is initialized with the number of work hours in a day. Saturday and Sunday are skipped.

Holidays are handled as an array of Date objects that are passed into the secondary ctor.

See Also:
Serialized Form

Field Summary
protected  java.util.Date[] holidays
          Additional days that should not be considered workdays.
protected  int hoursPerDay
          The number of work hours per day.
static long millisPerDay
          The number of milliseconds in a day.
protected  int remainderHours
          The additional hours that were not factored into a specific day.
 
Fields inherited from class java.util.GregorianCalendar
AD, BC
 
Fields inherited from class java.util.Calendar
AM, AM_PM, APRIL, areFieldsSet, AUGUST, DATE, DAY_OF_MONTH, DAY_OF_WEEK, DAY_OF_WEEK_IN_MONTH, DAY_OF_YEAR, DECEMBER, DST_OFFSET, ERA, FEBRUARY, FIELD_COUNT, fields, FRIDAY, HOUR, HOUR_OF_DAY, isSet, isTimeSet, JANUARY, JULY, JUNE, MARCH, MAY, MILLISECOND, MINUTE, MONDAY, MONTH, NOVEMBER, OCTOBER, PM, SATURDAY, SECOND, SEPTEMBER, SUNDAY, THURSDAY, time, TUESDAY, UNDECIMBER, WEDNESDAY, WEEK_OF_MONTH, WEEK_OF_YEAR, YEAR, ZONE_OFFSET
 
Constructor Summary
ElapsedTimeCalendar(int hoursPerDay, java.util.Date[] holidays)
          Create a new instance with the given number of work hours per day and an array of holidays.
 
Method Summary
 void addHours(int hours)
          Add the given number of hours to the current target date.
 java.lang.String getDateString()
          Returns a brief canonical date representation for use in reports.
 boolean isHoliday()
          Return true if this is a holiday, false otherwise.
 void skipHolidays()
          Skip past any holidays, including weekend days.
 
Methods inherited from class java.util.GregorianCalendar
add, clone, computeFields, computeTime, equals, getActualMaximum, getActualMinimum, getGreatestMinimum, getGregorianChange, getLeastMaximum, getMaximum, getMinimum, getTimeZone, hashCode, isLeapYear, roll, roll, setGregorianChange, setTimeZone
 
Methods inherited from class java.util.Calendar
after, before, clear, clear, compareTo, complete, get, getAvailableLocales, getFirstDayOfWeek, getInstance, getInstance, getInstance, getInstance, getMinimalDaysInFirstWeek, getTime, getTimeInMillis, internalGet, isLenient, isSet, set, set, set, set, setFirstDayOfWeek, setLenient, setMinimalDaysInFirstWeek, setTime, setTimeInMillis, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

millisPerDay

public static final long millisPerDay
The number of milliseconds in a day.

See Also:
Constant Field Values

hoursPerDay

protected int hoursPerDay
The number of work hours per day. Set when the calendar is created.


holidays

protected java.util.Date[] holidays
Additional days that should not be considered workdays.


remainderHours

protected int remainderHours
The additional hours that were not factored into a specific day.

Constructor Detail

ElapsedTimeCalendar

public ElapsedTimeCalendar(int hoursPerDay,
                           java.util.Date[] holidays)
Create a new instance with the given number of work hours per day and an array of holidays.

Method Detail

addHours

public void addHours(int hours)
Add the given number of hours to the current target date.


skipHolidays

public void skipHolidays()
Skip past any holidays, including weekend days.


isHoliday

public boolean isHoliday()
Return true if this is a holiday, false otherwise.


getDateString

public java.lang.String getDateString()
Returns a brief canonical date representation for use in reports. A typical example would be 21nov04. See DateUtil.getShortReadDate.