Date Format as "MM-dd-yyy" in <p:datatable> with dynamic column

senthil_sss picture senthil_sss · Mar 22, 2013 · Viewed 38.9k times · Source

I'm having a datatable with dynamic columns generated. i have a date column to be displayed, but in a specific format

in my datatable without dynamic columns generation ... i make the date to display in the specific format by this way

<p:dataTable .....>
  <p:column headerText="Date" id="dateID"
                        sortBy="#{iterator.updatedDate}"
                        filterBy="#{iterator.updatedDate}">

                        <h:outputText value="#{iterator.updatedDate}">
                            <f:convertDateTime pattern="MM-dd-yyyy" />
                        </h:outputText>

  </p:column>
</p:dataTable>

what could i do for getting the same outcome in my datatable with dynamic columns...

can any help me in fixing this...

Answer

Talles Penini picture Talles Penini · Jul 7, 2016

If your property is a Calendar type insert .time after it.

<h:outputText value="#{iterator.updatedDate.time}">
       <f:convertDateTime pattern="MM-dd-yyyy" />
 </h:outputText>