Class CmsJspInstanceDateBean
Provides convenient methods to format the date or date range.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Formatting options for dates.class
Transformer from formatting options to formatted dates. -
Constructor Summary
ConstructorDescriptionEmpty Constructor, for use as JavaBean.CmsJspInstanceDateBean
(Date start, Locale locale) Constructor to wrap a single date as instance date.CmsJspInstanceDateBean
(Date start, CmsJspDateSeriesBean series) Constructor taking start and the date series this instance date belongs to. -
Method Summary
Modifier and TypeMethodDescriptiongetEnd()
Returns the end time of this instance date.Returns an instance date bean wrapping only the end date of the original bean.Returns a lazy map from date format options to dates.Returns the start and end dates/times as "start - end" in long date format and short time format specific for the request locale.Returns the start and end dates/times as "start - end" in short date/time format specific for the request locale.boolean
getIsSet()
Checks if this instance date has been set or initialized.Returns a time of the last day where this instance date takes place.getStart()
Returns the start time of this instance date.Returns an instance date bean wrapping only the start date of the original bean.void
Initializes this date instance with a String for the locale.void
Initializes this date instance.boolean
Returns a flag, indicating if this instance date last over night.boolean
Indicates if this instance date lasts whole days.void
setEnd
(long endDate) Explicitly set the end time of this instance date using a long value.void
Explicitly set the end time of this instance date.void
setWholeDay
(Boolean isWholeDay) Set if this instance date is whole day.
-
Constructor Details
-
CmsJspInstanceDateBean
public CmsJspInstanceDateBean()Empty Constructor, for use as JavaBean.Requires to call one of the init() methods later.
- See Also:
-
CmsJspInstanceDateBean
Constructor taking start and the date series this instance date belongs to.- Parameters:
start
- the start date for this instance dateseries
- the date series this instance date belongs to
-
CmsJspInstanceDateBean
Constructor to wrap a single date as instance date.This will allow to use the format options.
- Parameters:
start
- the start date for this instance datelocale
- the locale used to format the date
-
-
Method Details
-
getEnd
Returns the end time of this instance date.- Returns:
- the end time of this instance date
-
getEndInstance
Returns an instance date bean wrapping only the end date of the original bean.- Returns:
- an instance date bean wrapping only the end date of the original bean.
-
getFormat
Returns a lazy map from date format options to dates. Supported formats are the values ofCmsJspInstanceDateBean.CmsDateFormatOption
.Each option must be backed up by four three keys in the message "bundle org.opencms.jsp.util.messages" for you locale: GUI_PATTERN_DATE_{Option}, GUI_PATTERN_DATE_TIME_{Option} and GUI_PATTERN_TIME_{Option}.
- Returns:
- a lazy map from date patterns to dates.
-
getFormatLong
Returns the start and end dates/times as "start - end" in long date format and short time format specific for the request locale.- Returns:
- the formatted date/time string.
-
getFormatShort
Returns the start and end dates/times as "start - end" in short date/time format specific for the request locale.- Returns:
- the formatted date/time string.
-
getIsSet
Checks if this instance date has been set or initialized.If the start date of the instance date is 0 milliseconds, we assume the instance date has not been set.
- Returns:
- true if this instance date has been set or initialized
-
getLastDay
Returns a time of the last day where this instance date takes place.This can be used to output the last calendar day of this instance date without time.
- Returns:
- a time of the last day where this instance date takes place
-
getStart
Returns the start time of this instance date.- Returns:
- the start time of this instance date
-
getStartInstance
Returns an instance date bean wrapping only the start date of the original bean.- Returns:
- an instance date bean wrapping only the start date of the original bean
-
init
Initializes this date instance.Use this only in case this date instance has been created as a JavaBean.
- Parameters:
start
- the start date for this instance datelocale
- the locale used to format the date
-
init
Initializes this date instance with a String for the locale.Use this only in case this date instance has been created as a JavaBean.
- Parameters:
start
- the start date for this instance datelocaleStr
- a String representing the locale used to format the date
-
isMultiDay
Returns a flag, indicating if this instance date last over night.- Returns:
true
if this instance date ends on another day than it starts,false
if it ends on the same day.
-
isWholeDay
Indicates if this instance date lasts whole days.- Returns:
- true if this instance date lasts whole days
-
setEnd
Explicitly set the end time of this instance date.If the provided date is
null
or a date before the start date, the end date defaults to the start date.- Parameters:
endDate
- the end time of this instance date
-
setEnd
Explicitly set the end time of this instance date using a long value.If the provided date is
null
or a date before the start date, the end date defaults to the start date.- Parameters:
endDate
- the end time of this instance date
-
setWholeDay
Set if this instance date is whole day.- Parameters:
isWholeDay
- flag, indicating if this instance date lasts the whole day - ifnull
the value defaults to the setting from the underlying date series.
-