We are using the <p:calendar together with the pattern attribute and it does not format the date as we expects. The pattern yyyy-MM-dd is supposed to fill out the string with zeros for months and days less than 10 but it is not doing that. When you for instance select the first of january 2010 you get the string 2010-1-1 and we would like to have it formatted as 2010-01-01.
<p:calendar id="startDatePicker" value="#{bean.startDate}"
pattern="yyyy-MM-dd" startWeekday="1"
required="true"
timeZone="GMT"
>
Any ideas how to solve this or is it a bug in Primefaces?
We are using Primefaces 1.0.0.RC.
<p:calendar and pattern problem
Hi,
I would recommend you to use an attached converter. I think, you can write your own converter and attach with f:converter. PrimeFaces uses java.text.SimpleDateFormat. I would not say that it's bad, but it's not good and flexible enough. We had to turn down SimpleDateFormat in our web-applications and are using JodaTime http://joda-time.sourceforge.net/. Since changing to JodaTime we are happy and don't have problems (format / parse) any more.
Best regards.
Oleg.
I would recommend you to use an attached converter. I think, you can write your own converter and attach with f:converter. PrimeFaces uses java.text.SimpleDateFormat. I would not say that it's bad, but it's not good and flexible enough. We had to turn down SimpleDateFormat in our web-applications and are using JodaTime http://joda-time.sourceforge.net/. Since changing to JodaTime we are happy and don't have problems (format / parse) any more.
Best regards.
Oleg.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin
Ok.
In my opinion, the JavaScript formatting / parsing is error-prone. I had headache with it. But it was in the past... In our web-apps we are offering now a selection of date / time patterns on the settings page. User can choose any pattern and it will be stored server-side in managed bean. So, if the user selects a date / time in the calendar an Ajax request is performed and a formatted date / time as string will come back and will be displayed in the calendar input field. I want to say that the proper formatting happens always on the server-side according to the selected by user date / time pattern.
- Oleg.
In my opinion, the JavaScript formatting / parsing is error-prone. I had headache with it. But it was in the past... In our web-apps we are offering now a selection of date / time patterns on the settings page. User can choose any pattern and it will be stored server-side in managed bean. So, if the user selects a date / time in the calendar an Ajax request is performed and a formatted date / time as string will come back and will be displayed in the calendar input field. I want to say that the proper formatting happens always on the server-side according to the selected by user date / time pattern.
- Oleg.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin
-
- Information
-
Who is online
Users browsing this forum: Google [Bot] and 44 guests