Osama Al-far
Osama Al-far

Reputation: 447

how to format a date to yyyy/mm/dd in af:column adf table?

i have af:table which have af:coulmn which contain Date .

the date is displayed on the format of mm/dd/yyyy : 7/16/2018

i want to display at as yyyy/mm/dd 2018/7/16

<af:column sortProperty="depositeDate" sortable="false" width="10%"
                 headerText="#{bundle.deposite_Date_Label}">
        <af:outputText value="#{row.depositeDate}"/>
</af:column>

how to achive that ?

Upvotes: 1

Views: 3252

Answers (2)

Amr Gawish
Amr Gawish

Reputation: 2025

Inside the <af:outputText> add the <af:convertDateTime> tag, so your code should look like the following:

<af:column sortProperty="depositeDate" sortable="false" width="10%" headerText="#{bundle.deposite_Date_Label}"> <af:outputText value="#{row.depositeDate}"> <af:convertDateTime pattern="yyyy/MM/dd" /> </af:outputText> </af:column> For reference about convertDateTime tag check this link.

PS: row.depositeDate needs to be a Date object, not a String!

Upvotes: 3

cyberdanes
cyberdanes

Reputation: 56

You could use DefaultDateFormatter to achieve this:

DefaultDateFormatter ddf = new DefaultDateFormatter();
String depositeDate = ddf.format("yyyy/MM/dd, depositeDatePlain);

Upvotes: 1

Related Questions