Package adams.core.base
Class BaseDateTimeMsec
- java.lang.Object
-
- adams.core.base.BaseObject
-
- adams.core.base.BaseDateTimeMsec
-
- All Implemented Interfaces:
CloneHandler<BaseObject>,DateValueSupporter,GrammarSupplier,Serializable,Comparable
public class BaseDateTimeMsec extends BaseObject implements GrammarSupplier, DateValueSupporter
Wrapper for a Date/Time string to be editable in the GOE. Dates have to be of format "yyyy-MM-dd HH:mm:ss.SSS".parses expressions as follows: (<date>|NOW|-INF|+INF|START|END) [(+<int>|-<int>) (SECOND|MINUTE|HOUR|DAY|BUSINESSDAY|WEEK|MONTH|YEAR)] Examples: 1999-12-31 01:02:03 1999-12-31 01:02:03 +1 MINUTE NOW +INF NOW +1 YEAR NOW +14 DAY Amounts can be chained as well: NOW -1 MONTH +1 DAY START and END can only be set programmatically; by default they equal to -INF and +INF.
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
FORMAT,setStart(Date),setEnd(Date), Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringENDthe placeholder for "end".static StringFORMATthe date/time format.static StringINF_FUTUREthe placeholder for "+INF" (infinity in the future).static StringINF_FUTURE_DATEthe "+INF" date.static StringINF_PASTthe placeholder for "-INF" (infinity in the past).static StringINF_PAST_DATEthe "-INF" date.protected BusinessDaysm_BusinessDayshow to interpret business days.protected Datem_Endthe end datetime to use.protected static DateFormatm_Formatfor formatting/parsing the dates.protected Datem_Startthe start datetime to use.static StringNOWthe placeholder for "now".static StringSTARTthe placeholder for "start".static StringTODAYthe placeholder for "today".static StringTOMORROWthe placeholder for "tomorrow".static StringYESTERDAYthe placeholder for "yesterday".-
Fields inherited from class adams.core.base.BaseObject
m_Internal, m_Properties, SUFFIX_DISPLAY, SUFFIX_VALUE
-
-
Constructor Summary
Constructors Constructor Description BaseDateTimeMsec()Initializes the date as NOW.BaseDateTimeMsec(String s)Initializes the object with the date to parse.BaseDateTimeMsec(Date date)Initializes the object with the specified date.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DateTimeMsecdateTimeMsecValue()Returns the DateTimeMsec value.DatedateValue()Returns the Date value.StringformatDateValue(String format)Returns the Date value formatted as a string.BusinessDaysgetBusinessDays()Returns what business days to use.DategetEnd()Returns the optional end datetime.protected static DateFormatgetFormat()Returns the formatter.StringgetGrammar()Returns a string representation of the grammar.DategetStart()Returns the optional start datetime.StringgetTipText()Returns a tool tip for the GUI editor (ignored if null is returned).StringgetValue()Returns the current string value.static BaseDateTimeMsecinfinityFuture()Returns a new BaseDate object initialized with the INF_FUTURE placeholder.static BaseDateTimeMsecinfinityPast()Returns a new BaseDate object initialized with the INF_PAST placeholder.protected voidinitialize()Initializes the internal object.booleanisInfinity()Checks whether the date/time is -INF or +INF.booleanisInfinityFuture()Checks whether the date/time is +INF.booleanisInfinityPast()Checks whether the date/time is -INF.booleanisValid(String value)Checks whether the string value is a valid presentation for this class.static BaseDateTimeMsecnow()Returns a new BaseDate object initialized with the NOW placeholder.protected Dateparse(String s, boolean quiet)Parses the given date string.voidsetBusinessDays(BusinessDays value)Sets what business days to use.voidsetEnd(Date value)Sets the optional end datetime.voidsetStart(Date value)Sets the optional start datetime.voidsetValue(String value)Sets the string value.StringstringValue()Returns the actual Date as string.-
Methods inherited from class adams.core.base.BaseObject
compareTo, equals, getClone, getInternal, getTemplates, getUnicode, hasFavoritesSupport, hashCode, isValidUnicode, newInstance, setUnicode, toObjectArray, toObjectArray, toString, toStringArray, toStringList
-
-
-
-
Field Detail
-
INF_PAST
public static final String INF_PAST
the placeholder for "-INF" (infinity in the past).- See Also:
- Constant Field Values
-
INF_PAST_DATE
public static final String INF_PAST_DATE
the "-INF" date.- See Also:
- Constant Field Values
-
INF_FUTURE
public static final String INF_FUTURE
the placeholder for "+INF" (infinity in the future).- See Also:
- Constant Field Values
-
INF_FUTURE_DATE
public static final String INF_FUTURE_DATE
the "+INF" date.- See Also:
- Constant Field Values
-
NOW
public static final String NOW
the placeholder for "now".- See Also:
- Constant Field Values
-
TODAY
public static final String TODAY
the placeholder for "today".- See Also:
- Constant Field Values
-
TOMORROW
public static final String TOMORROW
the placeholder for "tomorrow".- See Also:
- Constant Field Values
-
YESTERDAY
public static final String YESTERDAY
the placeholder for "yesterday".- See Also:
- Constant Field Values
-
START
public static final String START
the placeholder for "start".- See Also:
- Constant Field Values
-
END
public static final String END
the placeholder for "end".- See Also:
- Constant Field Values
-
FORMAT
public static final String FORMAT
the date/time format.- See Also:
- Constant Field Values
-
m_Format
protected static DateFormat m_Format
for formatting/parsing the dates.
-
m_Start
protected Date m_Start
the start datetime to use.
-
m_End
protected Date m_End
the end datetime to use.
-
m_BusinessDays
protected BusinessDays m_BusinessDays
how to interpret business days.
-
-
Constructor Detail
-
BaseDateTimeMsec
public BaseDateTimeMsec()
Initializes the date as NOW.- See Also:
NOW
-
BaseDateTimeMsec
public BaseDateTimeMsec(String s)
Initializes the object with the date to parse.- Parameters:
s- the date to parse
-
BaseDateTimeMsec
public BaseDateTimeMsec(Date date)
Initializes the object with the specified date.- Parameters:
date- the date to use
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the internal object.- Overrides:
initializein classBaseObject
-
getFormat
protected static DateFormat getFormat()
Returns the formatter.- Returns:
- the formatter
-
setStart
public void setStart(Date value)
Sets the optional start datetime.- Parameters:
value- the start datetime
-
getStart
public Date getStart()
Returns the optional start datetime.- Returns:
- the start datetime
-
setEnd
public void setEnd(Date value)
Sets the optional end datetime.- Parameters:
value- the end datetime
-
getEnd
public Date getEnd()
Returns the optional end datetime.- Returns:
- the end datetime
-
setBusinessDays
public void setBusinessDays(BusinessDays value)
Sets what business days to use.- Parameters:
value- the type
-
getBusinessDays
public BusinessDays getBusinessDays()
Returns what business days to use.- Returns:
- the type
-
parse
protected Date parse(String s, boolean quiet)
Parses the given date string.- Parameters:
s- the date string to parsequiet- whether to print exceptions or not- Returns:
- the parsed date, null in case of an error
-
isValid
public boolean isValid(String value)
Checks whether the string value is a valid presentation for this class.- Specified by:
isValidin classBaseObject- Parameters:
value- the string value to check- Returns:
- true if parseable date/time
-
setValue
public void setValue(String value)
Sets the string value.- Specified by:
setValuein classBaseObject- Parameters:
value- the string value
-
getValue
public String getValue()
Returns the current string value.- Specified by:
getValuein classBaseObject- Returns:
- the string value
-
dateValue
public Date dateValue()
Returns the Date value.- Specified by:
dateValuein interfaceDateValueSupporter- Returns:
- the Date value
-
dateTimeMsecValue
public DateTimeMsec dateTimeMsecValue()
Returns the DateTimeMsec value.- Returns:
- the DateTimeMsec value
-
stringValue
public String stringValue()
Returns the actual Date as string.- Returns:
- the actual date as string
-
formatDateValue
public String formatDateValue(String format)
Returns the Date value formatted as a string.- Specified by:
formatDateValuein interfaceDateValueSupporter- Returns:
- the formatted string
-
getTipText
public String getTipText()
Returns a tool tip for the GUI editor (ignored if null is returned).- Specified by:
getTipTextin classBaseObject- Returns:
- the tool tip
-
getGrammar
public String getGrammar()
Returns a string representation of the grammar.- Specified by:
getGrammarin interfaceGrammarSupplier- Returns:
- the grammar, null if not available
-
isInfinityFuture
public boolean isInfinityFuture()
Checks whether the date/time is +INF.- Returns:
- true if infinity future
-
isInfinityPast
public boolean isInfinityPast()
Checks whether the date/time is -INF.- Returns:
- true if infinity future
-
isInfinity
public boolean isInfinity()
Checks whether the date/time is -INF or +INF.- Returns:
- true if any infinity
-
now
public static BaseDateTimeMsec now()
Returns a new BaseDate object initialized with the NOW placeholder.- Returns:
- the BaseDate object
- See Also:
NOW
-
infinityFuture
public static BaseDateTimeMsec infinityFuture()
Returns a new BaseDate object initialized with the INF_FUTURE placeholder.- Returns:
- the BaseDate object
- See Also:
INF_FUTURE
-
infinityPast
public static BaseDateTimeMsec infinityPast()
Returns a new BaseDate object initialized with the INF_PAST placeholder.- Returns:
- the BaseDate object
- See Also:
INF_PAST
-
-