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 String
END
the placeholder for "end".static String
FORMAT
the date/time format.static String
INF_FUTURE
the placeholder for "+INF" (infinity in the future).static String
INF_FUTURE_DATE
the "+INF" date.static String
INF_PAST
the placeholder for "-INF" (infinity in the past).static String
INF_PAST_DATE
the "-INF" date.protected BusinessDays
m_BusinessDays
how to interpret business days.protected Date
m_End
the end datetime to use.protected static DateFormat
m_Format
for formatting/parsing the dates.protected Date
m_Start
the start datetime to use.static String
NOW
the placeholder for "now".static String
START
the placeholder for "start".static String
TODAY
the placeholder for "today".static String
TOMORROW
the placeholder for "tomorrow".static String
YESTERDAY
the 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 DateTimeMsec
dateTimeMsecValue()
Returns the DateTimeMsec value.Date
dateValue()
Returns the Date value.String
formatDateValue(String format)
Returns the Date value formatted as a string.BusinessDays
getBusinessDays()
Returns what business days to use.Date
getEnd()
Returns the optional end datetime.protected static DateFormat
getFormat()
Returns the formatter.String
getGrammar()
Returns a string representation of the grammar.Date
getStart()
Returns the optional start datetime.String
getTipText()
Returns a tool tip for the GUI editor (ignored if null is returned).String
getValue()
Returns the current string value.static BaseDateTimeMsec
infinityFuture()
Returns a new BaseDate object initialized with the INF_FUTURE placeholder.static BaseDateTimeMsec
infinityPast()
Returns a new BaseDate object initialized with the INF_PAST placeholder.protected void
initialize()
Initializes the internal object.boolean
isInfinity()
Checks whether the date/time is -INF or +INF.boolean
isInfinityFuture()
Checks whether the date/time is +INF.boolean
isInfinityPast()
Checks whether the date/time is -INF.boolean
isValid(String value)
Checks whether the string value is a valid presentation for this class.static BaseDateTimeMsec
now()
Returns a new BaseDate object initialized with the NOW placeholder.protected Date
parse(String s, boolean quiet)
Parses the given date string.void
setBusinessDays(BusinessDays value)
Sets what business days to use.void
setEnd(Date value)
Sets the optional end datetime.void
setStart(Date value)
Sets the optional start datetime.void
setValue(String value)
Sets the string value.String
stringValue()
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:
initialize
in 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:
isValid
in 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:
setValue
in classBaseObject
- Parameters:
value
- the string value
-
getValue
public String getValue()
Returns the current string value.- Specified by:
getValue
in classBaseObject
- Returns:
- the string value
-
dateValue
public Date dateValue()
Returns the Date value.- Specified by:
dateValue
in 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:
formatDateValue
in interfaceDateValueSupporter
- Returns:
- the formatted string
-
getTipText
public String getTipText()
Returns a tool tip for the GUI editor (ignored if null is returned).- Specified by:
getTipText
in classBaseObject
- Returns:
- the tool tip
-
getGrammar
public String getGrammar()
Returns a string representation of the grammar.- Specified by:
getGrammar
in 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
-
-