org.ofbiz.base.util
Class DateRange

java.lang.Object
  extended by org.ofbiz.base.util.DateRange
All Implemented Interfaces:
java.io.Serializable

public class DateRange
extends java.lang.Object
implements java.io.Serializable

An immutable range of dates.

See Also:
Serialized Form

Field Summary
protected  java.util.Date end
           
static DateRange FullRange
          A DateRange instance initialized to the widest possible range of dates.
static java.util.Date MAX_DATE
          A Date instance initialized to the latest possible date.
static java.util.Date MIN_DATE
          A Date instance initialized to the earliest possible date.
protected  java.util.Date start
           
 
Constructor Summary
protected DateRange()
           
  DateRange(java.util.Date start, java.util.Date end)
           
 
Method Summary
 boolean after(java.util.Date date)
          Returns true if this range occurs after date.
 boolean after(DateRange range)
          Returns true if the earliest date in this range occurs after the latest date in range.
 boolean before(java.util.Date date)
          Returns true if this range occurs before date.
 boolean before(DateRange range)
          Returns true if the latest date in this range occurs before the earliest date in range.
protected  java.util.Date downcastTimestamp(java.util.Date date)
           
 long durationInMillis()
          Returns this range's duration as a millisecond value.
 java.util.Date end()
          Returns the ending date of this range.
 java.sql.Timestamp endStamp()
          Returns the ending date of this range as a Timestamp instance.
 boolean equals(java.lang.Object obj)
           
 boolean includesDate(java.util.Date date)
          Returns true if date occurs within this range.
 boolean intersectsRange(java.util.Date start, java.util.Date end)
          Returns true if start and end intersect this range.
 boolean intersectsRange(DateRange range)
          Returns true if range intersects this range.
 boolean isAscending()
          Returns true if the ending date is later than the starting date.
 boolean isPoint()
          Returns true if the starting and ending dates are equal.
 java.util.Date start()
          Returns the starting date of this range.
 java.sql.Timestamp startStamp()
          Returns the starting date of this range as a Timestamp instance.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MIN_DATE

public static final java.util.Date MIN_DATE
A Date instance initialized to the earliest possible date.


MAX_DATE

public static final java.util.Date MAX_DATE
A Date instance initialized to the latest possible date.


FullRange

public static final DateRange FullRange
A DateRange instance initialized to the widest possible range of dates.


start

protected java.util.Date start

end

protected java.util.Date end
Constructor Detail

DateRange

protected DateRange()

DateRange

public DateRange(java.util.Date start,
                 java.util.Date end)
Parameters:
start - If null, defaults to MIN_DATE
end - If null, defaults to MAX_DATE
Method Detail

durationInMillis

public long durationInMillis()
Returns this range's duration as a millisecond value.

Returns:
Range duration in milliseconds

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

start

public java.util.Date start()
Returns the starting date of this range.

Returns:
Range starting date

startStamp

public java.sql.Timestamp startStamp()
Returns the starting date of this range as a Timestamp instance.

Returns:
Range starting date Timestamp

end

public java.util.Date end()
Returns the ending date of this range.

Returns:
Range ending date

endStamp

public java.sql.Timestamp endStamp()
Returns the ending date of this range as a Timestamp instance.

Returns:
Range ending date Timestamp

isAscending

public boolean isAscending()
Returns true if the ending date is later than the starting date.

Returns:
true if the ending date is later than the starting date

isPoint

public boolean isPoint()
Returns true if the starting and ending dates are equal.

Returns:
true if the starting and ending dates are equal

includesDate

public boolean includesDate(java.util.Date date)
Returns true if date occurs within this range.

Parameters:
date -
Returns:
true if date occurs within this range

before

public boolean before(java.util.Date date)
Returns true if this range occurs before date.

Parameters:
date -
Returns:
true if this range occurs before date

before

public boolean before(DateRange range)
Returns true if the latest date in this range occurs before the earliest date in range.

Parameters:
range -
Returns:
true if the latest date in this range occurs before the earliest date in range

after

public boolean after(java.util.Date date)
Returns true if this range occurs after date.

Parameters:
date -
Returns:
true if this range occurs after date

after

public boolean after(DateRange range)
Returns true if the earliest date in this range occurs after the latest date in range.

Parameters:
range -
Returns:
true if the earliest date in this range occurs after the latest date in range

intersectsRange

public boolean intersectsRange(DateRange range)
Returns true if range intersects this range.

Parameters:
range -
Returns:
true if range intersects this range

intersectsRange

public boolean intersectsRange(java.util.Date start,
                               java.util.Date end)
Returns true if start and end intersect this range.

Parameters:
start - If null, defaults to MIN_DATE
end - If null, defaults to MAX_DATE
Returns:
true if start and end intersect this range

downcastTimestamp

protected java.util.Date downcastTimestamp(java.util.Date date)