Search code examples
jsfinputtimerichfaces

type time in hh:mm format in jsf


The date format contains dd/mm/yyyy hh:mm:ss which can be used in this manner using <rich:calendar datePattern="dd/MM/yyyy HH:mm"
value="#{uCBController.uCBUnit2.ucbEsp.lastSD}"
button. but this gives option to modify only date (and may be along with time.)

But what I want is when select this button , it should display only time to select and modify, and saves in time format only.


Solution

  • Create two <rich:inputNumberSlider> components (one for picking the hours and one for picking the minutes). <rich:calendar> doesn't support picking only the time.

    <rich:inputNumberSpinner value="#{bean.hours}" minValue="0" maxValue="23" />
    <rich:inputNumberSpinner value="#{bean.minutes}" minValue="0" maxValue="59" />
    

    Then, in the managed bean, just create two properties with the correspoding accessors.

    public class Bean {
      private Integer hours;
    
      private Integer minutes;
    
      //getters, setters
    }