Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change the date format in jsf

Tags:

jsf

I've retrieved data from database and displayed it using

<h:column>
  <f:facet name="header">
   <h:outputText value=" Date"/>
  </f:facet>
  <h:outputText value="#{item.date}"></h:outputText>
</h:column>

the date here is displayed in YYYY-MM-DD, I want to change it to normal i.e., dd-mm-yyyy format.Can i get any suggestion??

like image 887
Mango Avatar asked Mar 22 '11 11:03

Mango


People also ask

How to convert string to date in JSF?

SimpleDateFormat df = new SimpleDateFormat(" dd MMM yyyy"); Date oneDate = new Date(startDate); df. format(oneDate);

How to input date in JSF?

JSF: Handling Dates in JSF Forms The user enters the student data into the form: first name, last name and hire date. The input format for the hire date is day, month, year. As an example For 1 May 2016, you would enter: 1-5-2016. Once the form is submitted, then the app will show the output.


1 Answers

Try a DateTime Converter:

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

See the Java EE tutorial for detailed information

like image 50
Matt Handy Avatar answered Oct 12 '22 07:10

Matt Handy