Package org.zkoss.zul

Class Datebox

    • Constructor Detail

      • Datebox

        public Datebox()
      • Datebox

        public Datebox​(java.util.Date date)
                throws WrongValueException
        Constructor with a given date.
        Parameters:
        date - the date to be assigned to this datebox initially.
        Notice that, if this datebox does not allow users to select the time (i.e., the format limited to year, month and day), the date specified here is better to set hour, minutes, seconds and milliseconds to zero (for the current timezone, TimeZones.getCurrent()), so it is easier to work with other libraries, such as SQL. Dates has a set of utilities to simplify the task.
        Throws:
        WrongValueException
      • Datebox

        public Datebox​(java.time.ZonedDateTime value)
                throws WrongValueException
        Constructor with a given date.
        Parameters:
        value - the date to be assigned to this datebox initially.
        Notice that, if this datebox does not allow users to select the time (i.e., the format limited to year, month and day), the date specified here is better to set hour, minutes, seconds and milliseconds to zero (for the current timezone, TimeZones.getCurrent()), so it is easier to work with other libraries, such as SQL. Dates has a set of utilities to simplify the task.
        Throws:
        WrongValueException
        Since:
        9.0.0
      • Datebox

        public Datebox​(java.time.LocalDateTime value)
                throws WrongValueException
        Constructor with a given date.
        Parameters:
        value - the date to be assigned to this datebox initially.
        Notice that, if this datebox does not allow users to select the time (i.e., the format limited to year, month and day), the date specified here is better to set hour, minutes, seconds and milliseconds to zero (for the current timezone, TimeZones.getCurrent()), so it is easier to work with other libraries, such as SQL. Dates has a set of utilities to simplify the task.
        Throws:
        WrongValueException
        Since:
        9.0.0
      • Datebox

        public Datebox​(java.time.LocalDate value)
                throws WrongValueException
        Constructor with a given date.
        Parameters:
        value - the date to be assigned to this datebox initially.
        Notice that, if this datebox does not allow users to select the time (i.e., the format limited to year, month and day), the date specified here is better to set hour, minutes, seconds and milliseconds to zero (for the current timezone, TimeZones.getCurrent()), so it is easier to work with other libraries, such as SQL. Dates has a set of utilities to simplify the task.
        Throws:
        WrongValueException
        Since:
        9.0.0
      • Datebox

        public Datebox​(java.time.LocalTime value)
                throws WrongValueException
        Constructor with a given date.
        Parameters:
        value - the date to be assigned to this datebox initially.
        Notice that, if this datebox does not allow users to select the time (i.e., the format limited to year, month and day), the date specified here is better to set hour, minutes, seconds and milliseconds to zero (for the current timezone, TimeZones.getCurrent()), so it is easier to work with other libraries, such as SQL. Dates has a set of utilities to simplify the task.
        Throws:
        WrongValueException
        Since:
        9.0.0
    • Method Detail

      • setWeekOfYear

        public void setWeekOfYear​(boolean weekOfYear)
        Sets whether enable to show the week number in the current calendar or not. [ZK EE]
        Since:
        6.5.0
      • isWeekOfYear

        public boolean isWeekOfYear()
        Returns whether enable to show the week number in the current calendar or not.

        Default: false

        Since:
        6.5.0
      • setStrictDate

        public void setStrictDate​(boolean strictDate)
        Sets whether or not date/time should be strict. If true, any invalid input like "Jan 0" or "Nov 31" would be refused. If false, it won't be checked and let lenient parsing decide.
        Since:
        8.6.0
      • isStrictDate

        public boolean isStrictDate()
        Returns whether date/time should be strict or not.

        Default: false.

        Since:
        8.6.0
      • getLocalizedFormat

        protected java.lang.String getLocalizedFormat()
        Returns the localized format, which is used when constructing a datebox.

        You might override this method to provide your own localized format.

      • isLenient

        public boolean isLenient()
        Returns whether date/time parsing is to be lenient or not.

        With lenient parsing, the parser may use heuristics to interpret inputs that do not precisely match this object's format. With strict parsing, inputs must match this object's format.

      • setLenient

        public void setLenient​(boolean lenient)
        Sets whether date/time parsing is to be lenient or not.

        Default: true.

        With lenient parsing, the parser may use heuristics to interpret inputs that do not precisely match this object's format. With strict parsing, inputs must match this object's format.

      • isButtonVisible

        public boolean isButtonVisible()
        Returns whether the button (on the right of the textbox) is visible.

        Default: true.

        Since:
        2.4.1
      • setButtonVisible

        public void setButtonVisible​(boolean visible)
        Sets whether the button (on the right of the textbox) is visible.
        Since:
        2.4.1
      • getPosition

        public java.lang.String getPosition()
        Returns:
        the datebox popup position
        Since:
        8.0.3
      • setPosition

        public void setPosition​(java.lang.String position)
        Position the popup datebox to the specified location.
        Parameters:
        position - where to position. Default: after_start Allowed values:
        • before_start
          the element appears above the anchor, aligned to the left.
        • before_center
          the element appears above the anchor, aligned to the center.
        • before_end
          the element appears above the anchor, aligned to the right.
        • after_start
          the element appears below the anchor, aligned to the left.
        • after_center
          the element appears below the anchor, aligned to the center.
        • after_end
          the element appears below the anchor, aligned to the right.
        • start_before
          the element appears to the left of the anchor, aligned to the top.
        • start_center
          the element appears to the left of the anchor, aligned to the middle.
        • start_after
          the element appears to the left of the anchor, aligned to the bottom.
        • end_before
          the element appears to the right of the anchor, aligned to the top.
        • end_center
          the element appears to the right of the anchor, aligned to the middle.
        • end_after
          the element appears to the right of the anchor, aligned to the bottom.
        • overlap/top_left
          the element overlaps the anchor, with anchor and element aligned at top-left.
        • top_center
          the element overlaps the anchor, with anchor and element aligned at top-center.
        • overlap_end/top_right
          the element overlaps the anchor, with anchor and element aligned at top-right.
        • middle_left
          the element overlaps the anchor, with anchor and element aligned at middle-left.
        • middle_center
          the element overlaps the anchor, with anchor and element aligned at middle-center.
        • middle_right
          the element overlaps the anchor, with anchor and element aligned at middle-right.
        • overlap_before/bottom_left
          the element overlaps the anchor, with anchor and element aligned at bottom-left.
        • bottom_center
          the element overlaps the anchor, with anchor and element aligned at bottom-center.
        • overlap_after/bottom_right
          the element overlaps the anchor, with anchor and element aligned at bottom-right.
        • at_pointer
          the element appears with the upper-left aligned with the mouse cursor.
        • after_pointer
          the element appears with the top aligned with the bottom of the mouse cursor, with the left side of the element at the horizontal position of the mouse cursor.
        Since:
        8.0.3
      • toStyle

        public static int toStyle​(java.lang.String format)
        Returns the styling index, or -111 if not matched.
      • getRealFormat

        public java.lang.String getRealFormat()
        Returns the real format, i.e., the combination of the format patterns, such as yyyy-MM-dd.

        As described in setFormat(java.lang.String), a developer could specify an abstract name, such as short, or an empty string as the format, and this method will convert it to a real date/time format.

        Overrides:
        getRealFormat in class FormatInputElement
        Since:
        5.0.7
      • setTimeZone

        public void setTimeZone​(java.util.TimeZone tzone)
        Sets the time zone that this component belongs to, or null if the default time zone is used.

        The default time zone is determined by TimeZones.getCurrent().

        Notice that if getDisplayedTimeZones() was called with a non-empty list, the time zone must be one of it. Otherwise (including tzone is null), the first timezone is selected.

        Overrides:
        setTimeZone in class DateTimeFormatInputElement
      • getDisplayedTimeZones

        public java.util.List<java.util.TimeZone> getDisplayedTimeZones()
        Returns a list of the time zones that will be displayed at the client and allow user to select.

        Default: null

        Since:
        3.6.3
      • setDisplayedTimeZones

        public void setDisplayedTimeZones​(java.util.List<java.util.TimeZone> dtzones)
        Sets a list of the time zones that will be displayed at the client and allow user to select.

        If the DateTimeFormatInputElement.getTimeZone() is null, the first time zone in the list is assumed.

        Parameters:
        dtzones - a list of the time zones to display. If empty, it assumed to be null.
        Since:
        3.6.3
      • setDisplayedTimeZones

        public void setDisplayedTimeZones​(java.lang.String dtzones)
        Sets a concatenation of a list of the time zones' ID, separated by comma, that will be displayed at the client and allow user to select.

        The time zone is retrieved by calling TimeZone.getTimeZone().

        Parameters:
        dtzones - a concatenation of a list of the timezones' ID, such as "America/Los_Angeles,GMT+8"
        Since:
        3.6.3
        See Also:
        setDisplayedTimeZones(List)
      • isTimeZonesReadonly

        public boolean isTimeZonesReadonly()
        Returns whether the list of the time zones to display is readonly. If readonly, the user cannot change the time zone at the client.
        Since:
        3.6.3
      • setTimeZonesReadonly

        public void setTimeZonesReadonly​(boolean readonly)
        Sets whether the list of the time zones to display is readonly. If readonly, the user cannot change the time zone at the client.
        Since:
        3.6.3
      • setOpen

        public void setOpen​(boolean open)
        Drops down or closes the calendar to select a date. only works while visible
        Since:
        3.0.1
        See Also:
        open(), close()
      • open

        public void open()
        Drops down the calendar to select a date. The same as setOpen(true).
        Since:
        3.0.1
      • close

        public void close()
        Closes the calendar if it was dropped down. The same as setOpen(false).
        Since:
        3.0.1
      • setConstraint

        public void setConstraint​(java.lang.String constr)
        Overrides:
        setConstraint in class InputElement
        Parameters:
        constr - a list of constraints separated by comma. Example: "between 20071012 and 20071223", "before 20080103"
      • getDateFormat

        protected java.text.DateFormat getDateFormat​(java.lang.String fmt)
        Returns the date format of the specified format

        Default: it uses SimpleDateFormat to format the date.

        Parameters:
        fmt - the pattern.
      • getShowTodayLink

        public boolean getShowTodayLink()
        Returns whether enable to show the link that jump to today in day view

        Default: false

        Returns:
        boolean
        Since:
        8.0.0
      • setShowTodayLink

        public void setShowTodayLink​(boolean showTodayLink)
        Sets whether enable to show the link that jump to today in day view
        Parameters:
        showTodayLink - show or hidden
        Since:
        8.0.0
      • getTodayLinkLabel

        public java.lang.String getTodayLinkLabel()
        Returns the label of the link that jump to today in day view

        Default: Today

        Returns:
        String
        Since:
        8.0.4
      • setTodayLinkLabel

        public void setTodayLinkLabel​(java.lang.String todayLinkLabel)
        Sets the label of the link that jump to today in day view
        Parameters:
        todayLinkLabel - today link label
        Since:
        8.0.4
      • getDefaultDateTime

        public java.time.LocalDateTime getDefaultDateTime()
        Returns the default datetime if the value is empty.

        Default: null (means current datetime)

        Since:
        9.0.0
      • setDefaultDateTime

        public void setDefaultDateTime​(java.time.LocalDateTime defaultDateTime)
        Sets the default datetime if the value is empty.
        Parameters:
        defaultDateTime - Default datetime. null means current datetime.
        Since:
        9.0.0
      • getSelectLevel

        public java.lang.String getSelectLevel()
        Returns the level that a user can select.

        Default: "day"

        Returns:
        the level that a user can select
        Since:
        9.5.1
      • setSelectLevel

        public void setSelectLevel​(java.lang.String selectLevel)
        Sets the level that a user can select. The valid options are "day", "month", and "year".
        Parameters:
        selectLevel - the level that a user can select
        Since:
        9.5.1
      • getClosePopupOnTimezoneChange

        public boolean getClosePopupOnTimezoneChange()
        Returns whether to auto close the datebox popup after changing the timezone.

        Default: true

        Returns:
        boolean
        Since:
        9.6.0
      • setClosePopupOnTimezoneChange

        public void setClosePopupOnTimezoneChange​(boolean closePopupOnTimezoneChange)
        Sets whether to auto close the datebox popup after changing the timezone.
        Parameters:
        closePopupOnTimezoneChange - shall close the datebox popup or not
        Since:
        9.6.0