|
ProgramixGenericLib v4.0.0 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.programix.time.PlainDateRange
public final class PlainDateRange
Immutable encapsulation of a period of time as expressed by a starting
PlainDate and an ending PlainDate. Either the starting
date or the ending date or both can be null.
If you need a time span that also includes time-of-day and/or
time zone information, see DateTimeRange.
The PlainDate class itself and the utility
DateTools have handy utilities for formatting and parsing
PlainDate instances to and from more human-readable
Strings.
PlainDate,
DateTime,
DateTimeRange,
Serialized Form| Field Summary | |
|---|---|
static PlainDateRange |
BOTH_OPEN
This PlainDateRange has both an undefined start and an undefined end. |
static Comparator |
NEWEST_FIRST_COMPARATOR
Compares two ranges placing ranges that are considered "newest" or "most recent" first. |
static Comparator |
OLDEST_FIRST_COMPARATOR
Compares two ranges placing ranges that are considered "oldest" first. |
static PlainDate |
OPEN
This constant can be used to specify that either the start or end of of the range is "open" (that is, it is not defined and can be considered to stretch out to infinity). |
| Constructor Summary | |
|---|---|
PlainDateRange(PlainDate start,
PlainDate end)
Creates a new instance with the specified start and end dates. |
|
PlainDateRange(String start,
String end)
Creates a new instance with the specified start and end dates. |
|
PlainDateRange(Value start,
Value end)
Creates a new instance with the specified start and end dates. |
|
| Method Summary | |
|---|---|
Object |
clone()
Simply returns a reference to this instance. |
int |
compareTo(Object otherRange)
Used to meet the requirements of the Comparable interface. |
int |
compareTo(PlainDateRange otherRange)
Compares this instance to otherRange as defined by OLDEST_FIRST_COMPARATOR. |
boolean |
contains(PlainDate plainDate)
Returns true if the specified PlainDate falls within this range (inclusive of both endpoints). |
static PlainDateRange |
createWithOpenEnd(PlainDate start)
Creates a new instance with an open end date and the specified start date. |
static PlainDateRange |
createWithOpenStart(PlainDate end)
Creates a new instance with an open start and the specified end date. |
boolean |
equals(Object obj)
Returns true if this instance's start and end dates exactly match the start and end dates of the passed instance. |
boolean |
equals(PlainDateRange otherPlainDate)
Returns true if this instance's start and end dates exactly match the start and end dates of the passed instance. |
PlainDate |
forceIntoRange(PlainDate value)
Forces the specified PlainDate into this range. |
PlainDate |
getEnd()
Returns the end of this range. |
String |
getEndString()
Returns the end of this range as a String in the ISO format yyyy-mm-dd. |
Value |
getEndValue()
Returns the end of this range as a Value. |
PlainDate |
getStart()
Returns the start of this range. |
String |
getStartString()
Returns the start of this range as a String in the ISO format yyyy-mm-dd. |
Value |
getStartValue()
Returns the start of this range as a Value. |
boolean |
hasDefinedEnd()
Returns true if this range has a defined end date. |
boolean |
hasDefinedStart()
Returns true if this range has a defined start date. |
int |
hashCode()
|
PlainDateRange |
setEnd(PlainDate newEnd)
Returns a new instance with the specified newEnd date and this instance's start date. |
PlainDateRange |
setEnd(String newEnd)
Returns a new instance with the specified newEnd date and this instance's start date. |
PlainDateRange |
setEnd(Value newEnd)
Returns a new instance with the specified newEnd date and this instance's start date. |
PlainDateRange |
setStart(PlainDate newStart)
Returns a new instance with the specified newStart date and this instance's end date. |
PlainDateRange |
setStart(String newStart)
Returns a new instance with the specified newStart date and this instance's end date. |
PlainDateRange |
setStart(Value newStart)
Returns a new instance with the specified newStart date and this instance's end date. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final PlainDate OPEN
public static final PlainDateRange BOTH_OPEN
PlainDateRange are immutable. In addition, there is no
need to create any other instances that have both ends open
(although is it permissible to create those instances).
public static final Comparator OLDEST_FIRST_COMPARATOR
Comparator:
open to 1997-02-02
open to 1997-09-09
open to 2000-02-02
open to 2000-03-03
open to open
1997-02-02 to 1997-02-02
1997-02-03 to 1997-02-03
1997-06-06 to 1997-09-09
1997-06-06 to 1997-10-10
1997-06-06 to open
1997-07-07 to 1997-08-08
1997-08-08 to 1997-09-09
1997-08-08 to open
1997-09-09 to open
Also see NEWEST_FIRST_COMPARATOR as it is not simply
the reverse of this comparator.
For additional permutations, see NullFirstComparator,
NullLastComparator, and ReverseComparator.
public static final Comparator NEWEST_FIRST_COMPARATOR
Comparator:
1997-09-09 to open
1997-08-08 to open
1997-06-06 to open
open to open
open to 2000-03-03
open to 2000-02-02
1997-06-06 to 1997-10-10
1997-08-08 to 1997-09-09
1997-06-06 to 1997-09-09
open to 1997-09-09
1997-07-07 to 1997-08-08
1997-02-03 to 1997-02-03
1997-02-02 to 1997-02-02
open to 1997-02-02
Also see OLDEST_FIRST_COMPARATOR as it is not simply
the reverse of this comparator.
For additional permutations, see NullFirstComparator,
NullLastComparator, and ReverseComparator.
| Constructor Detail |
|---|
public PlainDateRange(PlainDate start,
PlainDate end)
throws IllegalArgumentException
OPEN (or null)
can be used to indicate that one end or the other is open-ended.
Both the start and the end can be open, and if
you prefer, there is a shared, immutable instance that can be
used instead: BOTH_OPEN.
start - the beginning of the date range. Use OPEN
or null to indicate that the range is open-ended and has
no starting date.end - the ending of the date range. Use OPEN
or null to indicate that the range is open-ended and has
no end date.
IllegalArgumentException - if the start date
comes after the end date.PlainDateRange(Value, Value),
PlainDateRange(String, String)
public PlainDateRange(String start,
String end)
throws IllegalArgumentException
empty string
to indicate that one end or the other (or both) is open-ended.
start - the beginning of the date range.
Use null or an empty string
to indicate that the range is open-ended and has no starting date.end - the ending of the date range.
Use null or an empty string
to indicate that the range is open-ended and has no end date.
IllegalArgumentException - if the start date
comes after the end date.
Or, if one of the String's is not empty and can not be parsed
as a PlainDate (see PlainDate.create(String)).PlainDateRange(PlainDate, PlainDate),
PlainDateRange(Value, Value),
PlainDate.create(String)
public PlainDateRange(Value start,
Value end)
throws IllegalArgumentException
Value who's isEmpty()
method returns true to indicate that one end or the other
(or both) is open-ended.
start - the beginning of the date range.
Use null or an empty Value
to indicate that the range is open-ended and has no starting date.end - the ending of the date range.
Use null or an empty Value
to indicate that the range is open-ended and has no ending date.
IllegalArgumentException - if the start date
comes after the end date.
Or, if one of the Value's is not empty and can not be parsed
as a PlainDate (see Value.getPlainDateOrNull()).PlainDateRange(PlainDate, PlainDate),
PlainDateRange(String, String),
PlainDate.create(String)| Method Detail |
|---|
public static PlainDateRange createWithOpenStart(PlainDate end)
end - the end of the date range.public static PlainDateRange createWithOpenEnd(PlainDate start)
start - the start of the date range.
public PlainDateRange setStart(PlainDate newStart)
throws IllegalArgumentException
newStart - the new start date for the new instance or null.
IllegalArgumentException - if the start comes after the end.PlainDateRange(PlainDate, PlainDate)
public PlainDateRange setStart(String newStart)
throws IllegalArgumentException
newStart - the new start date for the new instance or null.
IllegalArgumentException - if the start comes after the end
or if the start is not empty and can't be parsed.PlainDateRange(String, String)
public PlainDateRange setStart(Value newStart)
throws IllegalArgumentException
newStart - the new start date for the new instance or null.
IllegalArgumentException - if the start comes after the end
or if the start is not empty and can't be parsed.PlainDateRange(Value, Value)
public PlainDateRange setEnd(PlainDate newEnd)
throws IllegalArgumentException
newEnd - the new end date for the new instance or null.
IllegalArgumentException - if the start comes after the end.PlainDateRange(PlainDate, PlainDate)
public PlainDateRange setEnd(String newEnd)
throws IllegalArgumentException
newEnd - the new end date for the new instance or null.
IllegalArgumentException - if the start comes after the end
or if the end is not empty and can't be parsed.PlainDateRange(String, String)
public PlainDateRange setEnd(Value newEnd)
throws IllegalArgumentException
newEnd - the new end date for the new instance or null.
IllegalArgumentException - if the start comes after the end
or if the end is not empty and can't be parsed.PlainDateRange(Value, Value)public boolean hasDefinedStart()
getStart()public PlainDate getStart()
OPEN
(null) is returned.
hasDefinedStart(),
getStartString(),
getStartValue()public String getStartString()
hasDefinedStart(),
getStart(),
getStartValue()public Value getStartValue()
hasDefinedStart(),
getStart(),
getStartString()public boolean hasDefinedEnd()
getEnd()public PlainDate getEnd()
OPEN
(null) is returned.
hasDefinedEnd()public String getEndString()
hasDefinedEnd(),
getEnd(),
getEndValue()public Value getEndValue()
hasDefinedEnd(),
getEnd(),
getEndString()public boolean contains(PlainDate plainDate)
public PlainDate forceIntoRange(PlainDate value)
throws IllegalArgumentException
contains(PlainDate)), then the passed date
is simply returned (no forcing is necessary).
If the range has a defined start and the specified date comes
before that start, then the start is returned.
If the range has a defined end and the specified date comes
after that end, then the end is returned.
value - the date to force into this range.
IllegalArgumentException - if the specified date is null.
public int compareTo(PlainDateRange otherRange)
throws IllegalArgumentException
OLDEST_FIRST_COMPARATOR.
IllegalArgumentException - if null if passed.public int compareTo(Object otherRange)
Comparable interface.
Simply casts the passed value and calls
compareTo(PlainDateRange).
If a type other than PlainDate is passed in,
a ClassCastException is thrown.
compareTo in interface Comparablepublic boolean equals(PlainDateRange otherPlainDate)
public boolean equals(Object obj)
equals in class Objectpublic int hashCode()
hashCode in class Objectpublic String toString()
toString in class Objectpublic Object clone()
clone in class Object
|
ProgramixGenericLib v4.0.0 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||