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(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(Date start, TimeDuration duration)
start
- start of rangeduration
- duration of rangepublic 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 contains(Date d)
d
- date to checkpublic void extend(Date d)
d
- given Datepublic void extend(DateRange dr)
dr
- given DateRangepublic TimeDuration getDuration()
public DateType getEnd()
public TimeDuration getResolution()
public DateType getStart()
public int hashCode()
public boolean included(Date d)
d
- date to checkpublic DateRange intersect(DateRange clip)
clip
- intersect with this date rangepublic boolean intersects(Date start_want, Date end_want)
start_want
- range starts hereend_want
- range ends herepublic boolean intersects(DateRange other)
other
- date rangepublic boolean isEmpty()
public boolean isPoint()
public void setDuration(TimeDuration duration)
duration
- duration of the intervalpublic void setEnd(DateType end)
end
- ending Datepublic void setResolution(TimeDuration resolution)
resolution
- the time resolutionpublic void setStart(DateType start)
start
- starting Datepublic boolean useDuration()
public boolean useEnd()
public boolean useResolution()
public boolean useStart()