Package org.jdesktop.swingx.calendar
Class DateSpan
- java.lang.Object
-
- org.jdesktop.swingx.calendar.DateSpan
-
public class DateSpan extends Object
An immutable representation of a time range. The time range is internally represented as two longs. The methods that take and returnDates create theDates as needed, so that if you modify returnedDates you will not effect theDateSpan. The end points are inclusive.- Version:
- $Revision: 542 $
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DateSpanadd(long start, long end)Returns a newDateSpanthat is the union of thisDateSpanand the passed in span.DateSpanadd(DateSpan span)Returns a newDateSpanthat is the union of thisDateSpanandspan.booleancontains(long time)Returns whether or not thisDateSpancontains the specified time.booleancontains(long start, long end)Returns whether or not thisDateSpancontains the specified date span.booleancontains(DateSpan span)Returns true if thisDateSpancontains the specifiedDateSpan.booleanequals(Object o)longgetEnd()Returns the end of the date span.DategetEndAsDate()Returns the end of the date span as aDate.longgetStart()Returns the start of the date span.DategetStartAsDate()Returns the start of the date span as aDate.inthashCode()booleanintersects(long start, long end)Returns true if the thisDateSpanintersects with the specified time.booleanintersects(DateSpan span)Returns true if the thisDateSpanintersects with the specifiedDateSpan.StringtoString()
-
-
-
Constructor Detail
-
DateSpan
public DateSpan(long start, long end)Creates aDateSpanbetween the two end points.- Parameters:
start- Beginning dateend- Ending date- Throws:
IllegalArgumentException- ifstartis afterend
-
-
Method Detail
-
getStart
public long getStart()
Returns the start of the date span.- Returns:
- start of the span.
-
getEnd
public long getEnd()
Returns the end of the date span.- Returns:
- end of the span.
-
getStartAsDate
public Date getStartAsDate()
Returns the start of the date span as aDate.- Returns:
- start of the span.
-
getEndAsDate
public Date getEndAsDate()
Returns the end of the date span as aDate.- Returns:
- end of the span.
-
contains
public boolean contains(DateSpan span)
Returns true if thisDateSpancontains the specifiedDateSpan.- Parameters:
span- Date to check- Returns:
- true if this DateSpan contains
span.
-
contains
public boolean contains(long time)
Returns whether or not thisDateSpancontains the specified time.- Parameters:
time- time check- Returns:
- true if this DateSpan contains
time.
-
contains
public boolean contains(long start, long end)Returns whether or not thisDateSpancontains the specified date span.- Parameters:
start- Start of time spanend- End of time- Returns:
- true if this
DateSpancontains the specified date span.
-
intersects
public boolean intersects(long start, long end)Returns true if the thisDateSpanintersects with the specified time.- Parameters:
start- Start timeend- End time- Returns:
- true if this
DateSpanintersects with the specified time.
-
intersects
public boolean intersects(DateSpan span)
Returns true if the thisDateSpanintersects with the specifiedDateSpan.- Parameters:
span- DateSpan to compare to- Returns:
- true if this
DateSpanintersects with the specified time.
-
add
public DateSpan add(DateSpan span)
Returns a newDateSpanthat is the union of thisDateSpanandspan.- Parameters:
span- DateSpan to add- Returns:
- union of this DateSpan and
span
-
add
public DateSpan add(long start, long end)
Returns a newDateSpanthat is the union of thisDateSpanand the passed in span.- Parameters:
start- Start of region to addend- End of region to end- Returns:
- union of this DateSpan and
start,end
-
-