Display only hours in the calendar component of Primefaces

2

How to give the user the option to select only hours and minutes in the component of Primefaces

I have two fields with start and end times to select, but even putting <p:calendar> on clicking to select the time, year, month, day, hour and minute is shown. I would like to just leave Hour and Minute visible to the user.

  • GridPanelwithfields

<p:panelGrid columns="2" rendered="#{horarioFuncionamentoController.selected != null}">
  <p:outputLabel value="Início" for="inicio" />
  <p:calendar id="inicio" 
      pattern="HH:mm" 
      value="#{horarioFuncionamentoBean.selected.inicio}" 
      title="Início" 
      showOn="button" />
  
  <p:outputLabel value="Fim" for="fim" />
  <p:calendar id="fim" 
    pattern="HH:mm" 
    value="#{horarioFuncionamentoBean.selected.fim}" 
    title="Fim" 
    showOn="button" />
</p:panelGrid>

I found a Post of two years ago on a similar subject, but I believe there might be some solution currently.

    
asked by anonymous 05.04.2017 / 03:50

1 answer

1

Try to put timeOnly="true".

<p:calendar id="inicio" value="#{horarioFuncionamentoBean.selected.inicio}" pattern="HH:mm" timeOnly="true" />

<p:calendar id="fim" value="#{horarioFuncionamentoBean.selected.fim}" pattern="HH:mm" timeOnly="true" />
    
05.04.2017 / 05:57