Thursday, May 5, 2011

With facelets what is the equivalent to fmt:formatDate?

I am converting a JSP web page to facelets view handler.

What is the equivalent to fmt:formatDate etc.?

I know that it isn't supported. But is there an alternative? A third level implementation?

From stackoverflow
  • Usually in JSF, you would add a (convertDateTime) converter to the control:

    <h:outputText value="#{dateConverterBean.now}">
        <f:convertDateTime type="date" dateStyle="short" />
    </h:outputText>
    

    The documentation for Facelets implies they use the same.

  • The f:convertDateTime converter uses GMT / UMT as the time zone for formatting the date/time. This is pretty annoying, and can lead to the incorrect local date and time being displayed. You can supply a time zone to the converter using a bean. I would suggest making your own converter. Only takes a few lines of code and allows more exacting formatting.

0 comments:

Post a Comment