PrimeFaces calendar change pattern after date selection

calendarjsf-2primefaces

I use PrimeFaces calendar component on page. Pattern attribute is set to MM/dd/yyyy HH:mm:ss. Component value attribute is linked to java.util.Date variable in bean. When i open the page date in format which i expect, but after change of the value, format will always change into different format.

Expected format – 06/15/2015 08:00:30

Format after change of value – 06/15/2015 8:00 AM

Component ussage.

<p:calendar value="#{someBean.someJava.UtilDateVariable}" pattern="MM/dd/yyyy HH:mm:ss" locale="en">
     <f:convertDateTime pattern="MM/dd/yyyy HH:mm:ss"/>
</p:calendar>

I already tried to check primefaces showcase and documentation, different locale specification and also usage of the localization script for current localization but with no effect.

Every suggestion is welcome.

Best Answer

You do not need <f:convertDateTime pattern="MM/dd/yyyy HH:mm:ss"/>. This tag converts String to Object and viceversa.

The Primefaces documentation only uses the Pattern attribute and sometimes the locale attribute causes troubles. Try:

<p:calendar value="#{someBean.someJava.UtilDateVariable}" pattern="MM/dd/yyyy HH:mm:ss"/>
Related Topic