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
Date
s create the Date
s as needed, so that
if you modify returned Date
s 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 newDateSpan
that is the union of thisDateSpan
and the passed in span.Returns a newDateSpan
that is the union of thisDateSpan
andspan
.boolean
contains
(long time) Returns whether or not thisDateSpan
contains the specified time.boolean
contains
(long start, long end) Returns whether or not thisDateSpan
contains the specified date span.boolean
Returns true if thisDateSpan
contains the specifiedDateSpan
.boolean
long
getEnd()
Returns the end of the date span.Returns the end of the date span as aDate
.long
getStart()
Returns the start of the date span.Returns the start of the date span as aDate
.int
hashCode()
boolean
intersects
(long start, long end) Returns true if the thisDateSpan
intersects with the specified time.boolean
intersects
(DateSpan span) Returns true if the thisDateSpan
intersects with the specifiedDateSpan
.toString()
-
Constructor Details
-
DateSpan
public DateSpan(long start, long end) Creates aDateSpan
between the two end points.- Parameters:
start
- Beginning dateend
- Ending date- Throws:
IllegalArgumentException
- ifstart
is afterend
-
DateSpan
Creates aDateSpan
between 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 thisDateSpan
contains the specifiedDateSpan
.- Parameters:
span
- Date to check- Returns:
- true if this DateSpan contains
span
.
-
contains
public boolean contains(long time) Returns whether or not thisDateSpan
contains 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 thisDateSpan
contains the specified date span.- Parameters:
start
- Start of time spanend
- End of time- Returns:
- true if this
DateSpan
contains the specified date span.
-
intersects
public boolean intersects(long start, long end) Returns true if the thisDateSpan
intersects with the specified time.- Parameters:
start
- Start timeend
- End time- Returns:
- true if this
DateSpan
intersects with the specified time.
-
intersects
Returns true if the thisDateSpan
intersects with the specifiedDateSpan
.- Parameters:
span
- DateSpan to compare to- Returns:
- true if this
DateSpan
intersects with the specified time.
-
add
Returns a newDateSpan
that is the union of thisDateSpan
andspan
.- Parameters:
span
- DateSpan to add- Returns:
- union of this DateSpan and
span
-
add
Returns a newDateSpan
that is the union of thisDateSpan
and 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
-