Class CmsJspInstanceDateBean


  • public class CmsJspInstanceDateBean
    extends java.lang.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.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Date getEnd()
      Returns the end time of this instance date.
      CmsJspInstanceDateBean getEndInstance()
      Returns an instance date bean wrapping only the end date of the original bean.
      java.util.Map<java.lang.String,​java.lang.String> getFormat()
      Returns a lazy map from date format options to dates.
      java.lang.String getFormatLong()
      Returns the start and end dates/times as "start - end" in long date format and short time format specific for the request locale.
      java.lang.String getFormatShort()
      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.
      java.util.Date getLastDay()
      Returns a time of the last day where this instance date takes place.
      java.util.Date getStart()
      Returns the start time of this instance date.
      CmsJspInstanceDateBean getStartInstance()
      Returns an instance date bean wrapping only the start date of the original bean.
      void init​(java.util.Date start, java.lang.String localeStr)
      Initializes this date instance with a String for the locale.
      void init​(java.util.Date start, java.util.Locale locale)
      Initializes this date instance.
      boolean isMultiDay()
      Returns a flag, indicating if this instance date last over night.
      boolean isWholeDay()
      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 setEnd​(java.util.Date endDate)
      Explicitly set the end time of this instance date.
      void setWholeDay​(java.lang.Boolean isWholeDay)
      Set if this instance date is whole day.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CmsJspInstanceDateBean

        public CmsJspInstanceDateBean​(java.util.Date start,
                                      CmsJspDateSeriesBean series)
        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​(java.util.Date start,
                                      java.util.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 Detail

      • getEnd

        public java.util.Date getEnd()
        Returns the end time of this instance date.

        Returns:
        the end time of this instance date
      • getEndInstance

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

        public java.util.Map<java.lang.String,​java.lang.String> 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

        public java.lang.String 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

        public java.lang.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 java.util.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 java.util.Date getStart()
        Returns the start time of this instance date.

        Returns:
        the start time of this instance date
      • getStartInstance

        public CmsJspInstanceDateBean 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​(java.util.Date start,
                         java.util.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​(java.util.Date start,
                         java.lang.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​(java.util.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​(java.lang.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.