Class CmsJspInstanceDateBean

java.lang.Object
org.opencms.jsp.util.CmsJspInstanceDateBean

public class CmsJspInstanceDateBean extends Object
An instance of a date series with a start and optional end time, usable to describe one date for events and similar contents.

Provides convenient methods to format the date or date range.

  • Constructor Details

    • 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 date
      series - the date series this instance date belongs to
    • CmsJspInstanceDateBean

      public CmsJspInstanceDateBean(Date start, Locale locale)
      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 date
      locale - the locale used to format the date
  • Method Details

    • getEnd

      public Date 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 of CmsJspInstanceDateBean.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

      public boolean 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

      public Date 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

      public Date 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

      public void init(Date start, Locale locale)
      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 date
      locale - the locale used to format the date
    • init

      public void init(Date start, String localeStr)
      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 date
      localeStr - a String representing the locale used to format the date
    • isMultiDay

      public boolean 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

      public boolean isWholeDay()
      Indicates if this instance date lasts whole days.

      Returns:
      true if this instance date lasts whole days
    • setEnd

      public void setEnd(Date endDate)
      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

      public void setEnd(long endDate)
      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

      public void setWholeDay(Boolean isWholeDay)
      Set if this instance date is whole day.
      Parameters:
      isWholeDay - flag, indicating if this instance date lasts the whole day - if null the value defaults to the setting from the underlying date series.