Portal Showcase
f:convertDateTime
The f:convertDateTime Facelet tag exposes the functionality of a DateTimeConverter inside Facelet views.General Usage
A custom converter pattern can be specified via the pattern attribute. The syntax of the pattern follows the format specified by SimpleDateFormat.Source Code
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://xmlns.jcp.org/jsf/core" xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:h="http://xmlns.jcp.org/jsf/html"> <h:form> <h:inputText id="date" converterMessage="#{i18n['converter-message']}" value="#{inputTextModelBean.date}"> <f:convertDateTime pattern="MM/dd/yyyy" /> </h:inputText> <br /> <h:message for="date" /> <hr /> <h:commandButton value="#{i18n['submit']}"> <f:ajax render="@form" execute="@form" /> </h:commandButton> <h:outputText id="modelValue" value="#{inputTextModelBean.date}"> <f:convertDateTime pattern="MM/dd/yyyy" /> </h:outputText> </h:form> </ui:composition>
@ManagedBean @RequestScoped public class InputTextModelBean { private Date date = new GregorianCalendar().getTime(); private String text; public Date getDate() { return date; } public String getText() { return text; } public void setDate(Date date) { this.date = date; } public void setText(String text) { this.text = text; } }
Liferay Faces Bridge Implementation 5.0.0 + Liferay Faces Portal 5.0.0 + Showcase Common 3.1.1 + Liferay Faces Util 3.4.1 + Mojarra 2.2.20