moos.ssds.model
Class DateRange

java.lang.Object
  extended bymoos.ssds.model.DateRange
All Implemented Interfaces:
IDateRange, java.io.Serializable

public class DateRange
extends java.lang.Object
implements java.io.Serializable, IDateRange

Description

Represents an interval of time. This class provides a facade for easily quering date ranges for objects implementing the IDateRange interface. Typical use is:

 IDateRange idr; // This can be a DataContainer, DataProducer, Event, Resource, etc.
  DateRange dr = idr.getDateRange();
  // Setting the start and end dates of a DateRange WILL set the dates of it's
  // IDateRange proxy
  dr.setStartDate(someStartDate);
  dr.setEndDate(someEndDate);
  Date someDate = new Date();

 // Does dr occur before someDate?
 boolean before = dr.before(someDate);

 // Does dr occur after someDate?
 boolean after = dr.after(someDate);

 // Does someDate occur during dr?
 boolean during = dr.during(someDate);

 // How long is dr?
 long durationMs = dr.duration();
 

UML

 
 

License

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. This information should not be published or distributed to third parties without specific written permission from MBARI.

Copyright 2003 MBARI. MBARI Proprietary Information. All rights reserved.

Version:
$Id: DateRange.java,v 1.2 2003/10/31 21:46:28 kgomes Exp $
Author:
Brian Schlining
See Also:
Serialized Form

Field Summary
static int AFTER
           
static int BEFORE
           
static int DURING
           
 
Constructor Summary
DateRange()
           
DateRange(IDateRange iDateRange)
          Proxy constructor.
 
Method Summary
 boolean after(java.util.Date date)
           
 boolean before(java.util.Date date)
           
 long duration()
           
 int durationDays()
           
 boolean during(java.util.Date date)
           
 IDateRange getDateRange()
           
 java.util.Date getEndDate()
           
 java.util.Date getStartDate()
           
 int relation(java.util.Date date)
           
 void setEndDate(java.util.Date endDate)
           
 void setStartDate(java.util.Date startDate)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BEFORE

public static final int BEFORE
See Also:
Constant Field Values

AFTER

public static final int AFTER
See Also:
Constant Field Values

DURING

public static final int DURING
See Also:
Constant Field Values
Constructor Detail

DateRange

public DateRange()

DateRange

public DateRange(IDateRange iDateRange)
Proxy constructor. Uses the data in the IDateRange

Method Detail

getStartDate

public java.util.Date getStartDate()
Specified by:
getStartDate in interface IDateRange

setStartDate

public void setStartDate(java.util.Date startDate)
Specified by:
setStartDate in interface IDateRange

getEndDate

public java.util.Date getEndDate()
Specified by:
getEndDate in interface IDateRange

setEndDate

public void setEndDate(java.util.Date endDate)
Specified by:
setEndDate in interface IDateRange

getDateRange

public IDateRange getDateRange()
Specified by:
getDateRange in interface IDateRange

relation

public int relation(java.util.Date date)
Returns:
-1 if the date is before, 0 during or 1 after the time period in the DateRange

before

public boolean before(java.util.Date date)
Returns:
true if the end of the daterange is before the given Date

during

public boolean during(java.util.Date date)
Returns:
true if the supplied date occurs during the DateRange.

after

public boolean after(java.util.Date date)
Returns:
true if the startDate of the dateRange occurs after the given date.

durationDays

public int durationDays()

duration

public long duration()
Returns:
The duration of the DateRange in milliseconds