Show only hours in the Primefaces Legend component

Asked

Viewed 659 times

2

How to display to the user the option to select only hours and minutes in the component <p:calendar> of Primefaces

I have two fields with start and end times to select, but even putting the pattern="HH:mm" by clicking to select the time, is shown year, month, Day, Hour and Minute. I would like to leave only Time and Minute visible to the user.

inserir a descrição da imagem aqui

  • Grid panel with fields

<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 from two years ago on a similar subject, but I believe there may currently be some solution.

1 answer

1


Try putting 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" />

Browser other questions tagged

You are not signed in. Login or sign up in order to post.