public class DateRange extends Object
Constructor and Description |
---|
DateRange()
default Constructor
|
DateRange(CalendarDateRange cdr) |
DateRange(Date start,
Date end)
Create Date Range from a start and end date
|
DateRange(DateRange range,
String timeUnits)
Create DateRange from another DateRange, with a different units of resolution.
|
DateRange(Date start,
TimeDuration duration)
Create Date Range from a start date and duration
|
DateRange(DateType start,
DateType end,
TimeDuration duration,
TimeDuration resolution)
Encapsulates a range of dates, using DateType start/end, and/or a TimeDuration.
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(Date d)
Same as included()
|
boolean |
equals(Object o) |
void |
extend(Date d)
Extend this date range by the given Date.
|
void |
extend(DateRange dr)
Extend this date range by the given one.
|
TimeDuration |
getDuration()
Get the duration of the interval
|
DateType |
getEnd()
Get the ending Date.
|
TimeDuration |
getResolution()
Get the time resolution.
|
DateType |
getStart()
Get the starting Date.
|
int |
hashCode()
Override Object.hashCode() to implement equals.
|
boolean |
included(Date d)
Determine if the given date is included in this date range.
|
DateRange |
intersect(DateRange clip)
Intersect with another date range
|
boolean |
intersects(Date start_want,
Date end_want)
Determine if the given range intersects this date range.
|
boolean |
intersects(DateRange other)
Determine if the given range intersects this date range.
|
boolean |
isEmpty()
If the range is empty
|
boolean |
isPoint()
Return true if start date equals end date, so date range is a point.
|
void |
setDuration(TimeDuration duration)
Set the duration of the interval.
|
void |
setEnd(DateType end)
Set the ending Date.
|
void |
setResolution(TimeDuration resolution)
Set the time resolution.
|
void |
setStart(DateType start)
Set the starting Date.
|
String |
toString() |
boolean |
useDuration()
Get if the duration is fixed.
|
boolean |
useEnd()
Get if the end is fixed.
|
boolean |
useResolution()
Get if the resolution is set.
|
boolean |
useStart()
Get if the start is fixed.
|
public DateRange() throws ParseException
ParseException
- artifact, cant happenpublic DateRange(CalendarDateRange cdr)
public DateRange(Date start, Date end)
start
- start of rangeend
- end of rangepublic DateRange(Date start, TimeDuration duration)
start
- start of rangeduration
- duration of rangepublic DateRange(DateRange range, String timeUnits) throws ParseException
range
- copy start and end from heretimeUnits
- make resolution using new TimeDuration( timeUnits)ParseException
- is units are not valid time unitspublic DateRange(DateType start, DateType end, TimeDuration duration, TimeDuration resolution)
start
- starting dateend
- ending dateduration
- time duration; may be nullresolution
- time resolution; may be nullpublic boolean included(Date d)
d
- date to checkpublic boolean contains(Date d)
d
- date to checkpublic boolean intersects(Date start_want, Date end_want)
start_want
- range starts hereend_want
- range ends herepublic boolean intersects(DateRange other)
other
- date rangepublic DateRange intersect(DateRange clip)
clip
- intersect with this date rangepublic void extend(DateRange dr)
dr
- given DateRangepublic void extend(Date d)
d
- given Datepublic DateType getStart()
public void setStart(DateType start)
start
- starting Datepublic DateType getEnd()
public void setEnd(DateType end)
end
- ending Datepublic TimeDuration getDuration()
public void setDuration(TimeDuration duration)
duration
- duration of the intervalpublic TimeDuration getResolution()
public void setResolution(TimeDuration resolution)
resolution
- the time resolutionpublic boolean useStart()
public boolean useEnd()
public boolean useDuration()
public boolean useResolution()
public boolean isPoint()
public boolean isEmpty()