Format the date with <f: convertDateTime> and display it in <h: outputText>

I want to show something like "2010-10-20 by Mary" in h: outputText. The date value is stored inside the MBean field named date1, while the username is stored inside the MBean field with the username. I use the following EL and UI expression:

<h:outputText value="#{MBean.date1} by #{MBean.username}">
   <f:convertDateTime pattern="YYYY-MM-DD" timeZone="#{configMB.timeZone}" />
</h:inputText>

The value may be displayed. However, it ignores the date format specified by f: convertDateTime. No matter how I change the format of the data, it always displays something like " 2010-06-08 12:35: 22.0 from Mary". How can I solve this problem ??

Update: Zenzen solution works with the following code changes.

<h:outputFormat value="{0, date, yyyy-MM-dd} by #{1}">
    <f:param value="#{MBean.date1}" />
    <f:param value="#{MBean.username}" />
</h:outputFormat>

h:inputText, h:outputFormat <f:param>? , <h:outputFormat> span, . <input type="text">, , , . , span, <input type="text"> css javascript?

+5
1

- :

<h:outputFormat value="{0, date, yyyy-MM-dd} by #{MBean.username}">
    <f:param value="#{MBean.date1}" />
</h:outputFormat>

, value="{0, date, yyyy-MM-dd}", , "by #{MBean.username}" everthhing ,

+16

All Articles