Package org.jdesktop.swingx.calendar
Class DateSpan
java.lang.Object
org.jdesktop.swingx.calendar.DateSpan
An immutable representation of a time range. The time range is
internally represented as two longs. The methods that take and return
Dates create the Dates as needed, so that
if you modify returned Dates you will not effect
the DateSpan. The end points are inclusive.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(long start, long end) Returns a newDateSpanthat is the union of thisDateSpanand the passed in 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.booleanReturns true if thisDateSpancontains the specifiedDateSpan.booleanlonggetEnd()Returns the end of the date span.Returns the end of the date span as aDate.longgetStart()Returns the start of the date span.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.toString()
-
Constructor Details
-
DateSpan
public DateSpan(long start, long end) Creates aDateSpanbetween the two end points.- Parameters:
start- Beginning dateend- Ending date- Throws:
IllegalArgumentException- ifstartis afterend
-
DateSpan
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 Details
-
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
Returns the start of the date span as aDate.- Returns:
- start of the span.
-
getEndAsDate
Returns the end of the date span as aDate.- Returns:
- end of the span.
-
contains
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
Returns true if the thisDateSpanintersects with the specifiedDateSpan.- Parameters:
span- DateSpan to compare to- Returns:
- true if this
DateSpanintersects with the specified time.
-
add
Returns a newDateSpanthat is the union of thisDateSpanandspan.- Parameters:
span- DateSpan to add- Returns:
- union of this DateSpan and
span
-
add
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
-
hashCode
public int hashCode() -
toString
-