com.jrefinery.data
Class TimePeriod

java.lang.Object
  extended by com.jrefinery.data.TimePeriod
All Implemented Interfaces:
MonthConstants, java.lang.Comparable
Direct Known Subclasses:
Day, FixedMillisecond, Hour, Millisecond, Minute, Month, Quarter, Second, Week, Year

public abstract class TimePeriod
extends java.lang.Object
implements java.lang.Comparable, MonthConstants

An abstract class representing a time period.

Convenient methods are provided for calculating the next and previous time periods.

Conversion methods are defined that return the first and last milliseconds of the time period. The results from these methods are timezone-dependent.

Subclasses of TimePeriod are required to be immutable.


Field Summary
static java.util.TimeZone DEFAULT_TIME_ZONE
          The default time zone.
static java.util.Calendar WORKING_CALENDAR
          A working calendar (recycle to avoid unnecessary object creation).
 
Fields inherited from interface com.jrefinery.date.MonthConstants
APRIL, AUGUST, DECEMBER, FEBRUARY, JANUARY, JULY, JUNE, MARCH, MAY, NOVEMBER, OCTOBER, SEPTEMBER
 
Constructor Summary
TimePeriod()
           
 
Method Summary
 long getEnd()
          Returns the last millisecond of the time period, evaluated in the default time zone.
abstract  long getEnd(java.util.Calendar calendar)
          Returns the last millisecond of the time period, evaluated using the supplied calendar (which incorporates a timezone).
 long getEnd(java.util.TimeZone zone)
          Returns the last millisecond of the time period, evaluated within a specific time zone.
 long getMiddle()
          Returns the millisecond closest to the middle of the time period, evaluated in the default time zone.
 long getMiddle(java.util.Calendar calendar)
          Returns the millisecond closest to the middle of the time period, evaluated using the supplied calendar (which incorporates a timezone).
 long getMiddle(java.util.TimeZone zone)
          Returns the millisecond closest to the middle of the time period, evaluated within a specific time zone.
 long getStart()
          Returns the first millisecond of the time period, evaluated in the default time zone.
abstract  long getStart(java.util.Calendar calendar)
          Returns the first millisecond of the time period, evaluated using the supplied calendar (which incorporates a timezone).
 long getStart(java.util.TimeZone zone)
          Returns the first millisecond of the time period, evaluated within a specific time zone.
abstract  TimePeriod next()
          Returns the time period following this one, or null if some limit has been reached.
abstract  TimePeriod previous()
          Returns the time period preceding this one, or null if some lower limit has been reached.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Field Detail

DEFAULT_TIME_ZONE

public static final java.util.TimeZone DEFAULT_TIME_ZONE
The default time zone.


WORKING_CALENDAR

public static final java.util.Calendar WORKING_CALENDAR
A working calendar (recycle to avoid unnecessary object creation).

Constructor Detail

TimePeriod

public TimePeriod()
Method Detail

previous

public abstract TimePeriod previous()
Returns the time period preceding this one, or null if some lower limit has been reached.

Returns:
The previous time period.

next

public abstract TimePeriod next()
Returns the time period following this one, or null if some limit has been reached.

Returns:
The next time period.

getStart

public long getStart()
Returns the first millisecond of the time period, evaluated in the default time zone.

Returns:
The first millisecond of the time period.

getStart

public long getStart(java.util.TimeZone zone)
Returns the first millisecond of the time period, evaluated within a specific time zone.

Parameters:
zone - The time zone.
Returns:
The first millisecond of the time period.

getStart

public abstract long getStart(java.util.Calendar calendar)
Returns the first millisecond of the time period, evaluated using the supplied calendar (which incorporates a timezone).

Parameters:
calendar - The calendar.
Returns:
The first millisecond of the time period.

getEnd

public long getEnd()
Returns the last millisecond of the time period, evaluated in the default time zone.

Returns:
The last millisecond of the time period.

getEnd

public long getEnd(java.util.TimeZone zone)
Returns the last millisecond of the time period, evaluated within a specific time zone.

Parameters:
zone - The time zone.
Returns:
The last millisecond of the time period.

getEnd

public abstract long getEnd(java.util.Calendar calendar)
Returns the last millisecond of the time period, evaluated using the supplied calendar (which incorporates a timezone).

Parameters:
calendar - The calendar.
Returns:
The last millisecond of the time period.

getMiddle

public long getMiddle()
Returns the millisecond closest to the middle of the time period, evaluated in the default time zone.

Returns:
The millisecond closest to the middle of the time period.

getMiddle

public long getMiddle(java.util.TimeZone zone)
Returns the millisecond closest to the middle of the time period, evaluated within a specific time zone.

Parameters:
zone - The time zone.
Returns:
The millisecond closest to the middle of the time period.

getMiddle

public long getMiddle(java.util.Calendar calendar)
Returns the millisecond closest to the middle of the time period, evaluated using the supplied calendar (which incorporates a timezone).

Parameters:
calendar - The calendare.
Returns:
The millisecond closest to the middle of the time period.


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.