Reputation: 10777
I have a variable stored in TIMESTAMP format in db. It stores time like this:
2013-07-15 22:00:45
I want to take this and use it in a h:outputText item. I make a database search, and store the results in a resultset.
java.util.Date dt= res.getTimestamp(5);
Then i want to use this date, which was read from database, in an outputtext item. But doing the following does not work:
<h:outputText value="#{list.date}"
Where list
is an ArrayList
. I am sure that list.date is the date I read from database but I cannot get its value with the format I specified. So how can I do this?
Upvotes: 0
Views: 1432
Reputation: 6828
I guess you can use JSF's convertDateTime tag.
e.g. :
<h:outputText value="#{list.date}">
<f:convertDateTime pattern="d-M-yyyy" />
</h:outputText>
See http://www.jsftoolbox.com/documentation/help/12-TagReference/core/f_convertDateTime.html
Upvotes: 2
Reputation: 51711
<h:outputText value="#{list.date}">
<f:convertDateTime type="both" pattern="YYYY-MM-dd HH:mm:ss"/>
</h:outputText>
Upvotes: 3