Package org.jdesktop.swingx.calendar
Class DateSpan
- java.lang.Object
-
- org.jdesktop.swingx.calendar.DateSpan
-
public class DateSpan extends java.lang.ObjectAn 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$
-
-
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(java.lang.Object o)longgetEnd()Returns the end of the date span.java.util.DategetEndAsDate()Returns the end of the date span as aDate.longgetStart()Returns the start of the date span.java.util.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.java.lang.StringtoString()
-
-
-
Constructor Detail
-
DateSpan
public DateSpan(long start, long end)Creates aDateSpanbetween the two end points.- Parameters:
start- Beginning dateend- Ending date- Throws:
java.lang.IllegalArgumentException- ifstartis afterend
-
DateSpan
public DateSpan(java.util.Date start, java.util.Date end)Creates aDateSpanbetween the two end points. This is a conveniance constructor that is equivalent tonew Date(start.getTime(), end.getTime());.- Parameters:
start- Beginning dateend- Ending date
-
-
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 java.util.Date getStartAsDate()
Returns the start of the date span as aDate.- Returns:
- start of the span.
-
getEndAsDate
public java.util.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
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-