public class DateHolder extends Object
Constructor and Description |
---|
DateHolder()
Construct a date holder in the daily domain and initialize
it with the current time.
|
DateHolder(TimeDomain domain)
Construct a date holder in the given time domain and initialize it
with the current time.
|
Modifier and Type | Method and Description |
---|---|
void |
allowEmptyDate(boolean allow)
Set a flag to allow or disallow empty dates.
|
TimeIndex |
getDate()
Return the date evaluated in the time domain of the value holder.
|
TimeIndex |
getDate(Range context)
Return the date evaluated in the context of the given range.
|
String |
getDateText()
Return the text of the day expression set with
setDate . |
protected static int |
getLargeIncrement(Resolution unit)
Return the number of units for a large increment in the given resolution.
|
TimeDomain |
getTimeDomain()
Return the time domain.
|
void |
incrDate(boolean up,
boolean large)
Increase or decrease the date by a unit or by a large amount.
|
void |
incrDate(int increment)
Increment the date by the given amount.
|
void |
reset(TimeDomain domain)
Change the time domain.
|
void |
resetToCurrentTime()
Change the date to the current time.
|
void |
setDate(String date)
Set the date.
|
public DateHolder(TimeDomain domain)
domain
- a non-null time domainpublic DateHolder()
protected static int getLargeIncrement(Resolution unit)
unit
- a non-null resolutionpublic TimeDomain getTimeDomain()
public void allowEmptyDate(boolean allow)
allow
- if true, empty dates will be allowedpublic void reset(TimeDomain domain) throws T2Exception
domain
- the non-null new time domainT2Exception
public void resetToCurrentTime()
public void setDate(String date) throws T2Exception
DayExpression
for the valid syntax of dates.date
- a day expressionT2Exception
allowEmptyDate(boolean)
public void incrDate(int increment) throws T2Exception
resetToToday()
.increment
- a positive or negative numberT2Exception
public void incrDate(boolean up, boolean large) throws T2Exception
up
- if true increase, else decreaselarge
- if true use a large amount, else a single unitT2Exception
public String getDateText()
setDate
.
If a date was never set, an empty string is returned.
Do get a date as a string, use getDate()
and
toString()
.
The difference between the two ways becomes important when the date is a day expression: this method does not resolve the expression (and there is no risk of error caused by the presence of unresolved keywords in the day expression).
The method never returns null.
public TimeIndex getDate() throws T2Exception
T2Exception
public TimeIndex getDate(Range context) throws T2Exception
context
- a non-null rangeT2Exception
Copyright © 2017. All rights reserved.