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...
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>
You could create accessor methods in your backing bean that enable you to directly get the Date in the desired format, as a String.
Take this example:
public class MyBean{
private Date myDate;
public Date getMyDate() {
return myDate;
}
public String getMyFormattedDate() {
return new SimpleDateFormat("dd-MM-yyyy").format(myDate);
}
}
Then, in your dataTable, the property "myFormattedDate" should be called, so the formatted Date gets printed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With