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??
SimpleDateFormat df = new SimpleDateFormat(" dd MMM yyyy"); Date oneDate = new Date(startDate); df. format(oneDate);
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.
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
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