Date Header Filtering

I ran into a specific 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 filtering dates will be wonderful. 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>

filtering is not correct. Actually my observation with the language version of the date format is something like

11/20/2013

but even if I type Wed Nov .. I can see the filtered results. I also noticed that without language, the date is sent as

Wed Nov 20 13:43:37 CET 2013 Therefore, I think it is filtered by the last date, even if we see a different date template on the screen.

+4
source share
1 answer

, (filterBy="#{car.dateOfManufacturing}"). bean.

:

RowData​​strong > : String entry1, String entry2, String dateString, Date date.

bean :

public List<RowData> getTestData() {
  DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
(...)
  entries.add(new RowData("a1", "b1", dateFormat.format(new Date()), currentDate()));
(...)
return entries;

XHTML:

<p:column id="date" headerText="Simple date"
                    filterBy="#{entry.dateString}"
                    filterMatchMode="contains">
         <p:outputLabel value="#{entry.dateString}"  >
         </p:outputLabel>
</p:column>

:

<p:column id="dateLocale" headerText="Locale date"
                          filterBy="#{entry.date}"
                          filterMatchMode="contains">
         <p:outputLabel value="#{entry.date}"  >
            <f:convertDateTime locale="de"  />
         </p:outputLabel>
</p:column>

:

enter image description here

. , , , .

, .

+4

All Articles