I came accross a particular problem. I have a datatable in which i want to filter dates in primefaces. when I use
<p:column id="date" headerText="Manufacturing date"
filterBy="#{car.dateOfManufacturing}"
filterMatchMode="contains">
<p:outputLabel value="#{car.dateOfManufacturing}" >
</p:outputLabel>
</p:column>
Then the filtering of dates happen fine. But when i use
<p:column id="date" headerText="Manufacturing date"
filterBy="#{car.dateOfManufacturing}"
filterMatchMode="contains">
<p:outputLabel value="#{car.dateOfManufacturing}" >
<f:convertDateTime locale="de" />
</p:outputLabel>
</p:column>
the filtering does not happen properly. In fact my observation is with the locale the date format is something like
20.11.2013
but even if I type Wed Nov .. i am able to see filtered results.
I also observed that without locale the date is dispayed as
Wed Nov 20 13:43:37 CET 2013
So i guess it is getting filtered according the latter date even though we see a different date pattern on the screen.
Best Answer
I think need to convert your date before add to filter (
filterBy="#{car.dateOfManufacturing}"
). One of the simple solution is convert date to string with simple date format in bean.Here is my code:
My RowData containts:
String entry1, String entry2, String dateString, Date date
.My bean method for fill data:
and my XHTML:
Now I add your code to my table:
My table:
Filtering works fine with these three date in locale date column. Perhaps, if I start test this issue with many date, the result will be same which described in your answer.
So, I offer covert date to string or use calendar.