public class DateRange
extends java.lang.Object
Constructor and Description |
---|
DateRange()
default Constructor
|
DateRange(java.util.Date start,
java.util.Date end)
Create Date Range from a start and end date
|
DateRange(DateRange range,
java.lang.String timeUnits)
Create DateRange from another DateRange, with a different units of resolution.
|
DateRange(java.util.Date start,
TimeDuration duration)
Create Date Range from a start date and duration
|
DateRange(DateType start,
DateType end,
TimeDuration duration,
TimeDuration resolution)
Encapsolates a range of dates, using DateType start/end, and/or a TimeDuration.
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(java.util.Date d)
Same as included()
|
boolean |
equals(java.lang.Object o) |
void |
extend(java.util.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(java.util.Date d)
Determine if the given date is included in this date range.
|
DateRange |
intersect(DateRange clip)
Intersect with another date range
|
boolean |
intersects(java.util.Date start_want,
java.util.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.
|
java.lang.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 java.text.ParseException
java.text.ParseException
- artifact, cant happenpublic DateRange(java.util.Date start, java.util.Date end)
start
- start of rangeend
- end of rangepublic DateRange(java.util.Date start, TimeDuration duration)
start
- start of rangeduration
- duration of rangepublic DateRange(DateRange range, java.lang.String timeUnits) throws java.lang.Exception
range
- copy start and end from heretimeUnits
- make resolution using new TimeDuration( timeUnits)java.lang.Exception
- is units are not valid time unitspublic DateRange(DateType start, DateType end, TimeDuration duration, TimeDuration resolution)
start
- starting dateend
- ending dateduration
- time durationresolution
- time resolution; optionalpublic boolean included(java.util.Date d)
d
- date to checkpublic boolean contains(java.util.Date d)
d
- date to checkpublic boolean intersects(java.util.Date start_want, java.util.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(java.util.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()
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object