Prime faces calendar with pattern “hh:mm a”


I need to use prime faces calendar to fill time ONLY as the following :

      <p:calendar pattern="hh:mm a" value="#{bean.startTime}"/>
      <p:commandButton value="Save" actionListener="#{bean.saveAppointment}" />

But the saveAppointment method not fired at all. and without any Exception.

After tracing the issue I have concluded that the issue from the date conversion that primefaces uses under the cover.That is because when I omit a from the pattern i.e.(the pattern become pattern="hh:mm"). Then the action fired normally without any issue.

Note Primefaces version is 6


Check option: timeOnly="true".

By : szarotka

I have found a workaround by using pattern="HH:mm" and the capital H will make the hours 0-23 based.

I don't believe there is any way to control the user's browser, mainly because that would mess with their set preferences, but also because users are usually about not wanting their product to access their personal computer.

By : Boo89100

This video can help you solving your question :)
By: admin