Package org.apache.ofbiz.base.util
Class DateRange
- java.lang.Object
-
- org.apache.ofbiz.base.lang.ComparableRange<java.util.Date>
-
- org.apache.ofbiz.base.util.DateRange
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<ComparableRange<java.util.Date>>
,Range<java.util.Date>
public class DateRange extends ComparableRange<java.util.Date> implements java.io.Serializable
An immutable range of dates. This class is here for backward compatibility - new code should useComparableRange<Date>
instead.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static DateRange
FullRange
ADateRange
instance initialized to the widest possible range of dates.static java.util.Date
MAX_DATE
ADate
instance initialized to the latest possible date.static java.util.Date
MIN_DATE
ADate
instance initialized to the earliest possible date.-
Fields inherited from class org.apache.ofbiz.base.lang.ComparableRange
end, isPoint, start
-
-
Constructor Summary
Constructors Constructor Description DateRange(java.util.Date start, java.util.Date end)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
after(java.util.Date date)
Returnstrue
if this range occurs aftervalue
.boolean
before(java.util.Date date)
Returnstrue
if this range occurs beforevalue
.long
durationInMillis()
Returns this range's duration as a millisecond value.java.util.Date
end()
Returns the ending value of this range.java.sql.Timestamp
endStamp()
Returns the ending date of this range as aTimestamp
instance.boolean
includesDate(java.util.Date date)
Returnstrue
ifdate
occurs within this range.boolean
intersectsRange(java.util.Date start, java.util.Date end)
Returnstrue
ifstart
andend
intersect this range.boolean
intersectsRange(DateRange range)
Returnstrue
ifrange
intersects this range.java.util.Date
start()
Returns the starting value of this range.java.sql.Timestamp
startStamp()
Returns the starting date of this range as aTimestamp
instance.protected static java.util.Date
timestampToDate(java.util.Date date)
-
-
-
Field Detail
-
MIN_DATE
public static final java.util.Date MIN_DATE
ADate
instance initialized to the earliest possible date.
-
MAX_DATE
public static final java.util.Date MAX_DATE
ADate
instance initialized to the latest possible date.
-
FullRange
public static final DateRange FullRange
ADateRange
instance initialized to the widest possible range of dates.
-
-
Method Detail
-
timestampToDate
protected static java.util.Date timestampToDate(java.util.Date date)
-
after
public boolean after(java.util.Date date)
Description copied from interface:Range
Returnstrue
if this range occurs aftervalue
.- Specified by:
after
in interfaceRange<java.util.Date>
- Overrides:
after
in classComparableRange<java.util.Date>
- Parameters:
date
- The value to test- Returns:
true
if this range occurs aftervalue
-
before
public boolean before(java.util.Date date)
Description copied from interface:Range
Returnstrue
if this range occurs beforevalue
.- Specified by:
before
in interfaceRange<java.util.Date>
- Overrides:
before
in classComparableRange<java.util.Date>
- Parameters:
date
- The value to test- Returns:
true
if this range occurs beforevalue
-
durationInMillis
public long durationInMillis()
Returns this range's duration as a millisecond value.- Returns:
- Range duration in milliseconds
-
end
public java.util.Date end()
Description copied from interface:Range
Returns the ending value of this range.- Specified by:
end
in interfaceRange<java.util.Date>
- Overrides:
end
in classComparableRange<java.util.Date>
- Returns:
- Ending value
-
endStamp
public java.sql.Timestamp endStamp()
Returns the ending date of this range as aTimestamp
instance.- Returns:
- Range ending date
Timestamp
-
includesDate
public boolean includesDate(java.util.Date date)
Returnstrue
ifdate
occurs within this range.- Parameters:
date
-- Returns:
true
ifdate
occurs within this range
-
intersectsRange
public boolean intersectsRange(java.util.Date start, java.util.Date end)
Returnstrue
ifstart
andend
intersect this range.
-
intersectsRange
public boolean intersectsRange(DateRange range)
Returnstrue
ifrange
intersects this range.- Parameters:
range
-- Returns:
true
ifrange
intersects this range
-
start
public java.util.Date start()
Description copied from interface:Range
Returns the starting value of this range.- Specified by:
start
in interfaceRange<java.util.Date>
- Overrides:
start
in classComparableRange<java.util.Date>
- Returns:
- Starting value
-
startStamp
public java.sql.Timestamp startStamp()
Returns the starting date of this range as aTimestamp
instance.- Returns:
- Range starting date
Timestamp
-
-