JSF Convert dates for title attribute

痞子三分冷 提交于 2020-01-11 13:30:09

问题


I need to put a date into the title attribute of an image so that it displays when the user puts the mouse over. Problem is I would like to change the date format.

Any ideas?

<ice:graphicImage value="bean.image" title="#{bean.date}"/>

回答1:


Either do it directly in a getter method

public String getDate() {
    return new SimpleDateFormat("yyyy-MM-dd").format(this.date); 
}

or grab JSTL's <fmt:formatDate>.

<fmt:formatDate value="#{bean.date}" pattern="yyyy-MM-dd" var="date" />
<ice:graphicImage value="bean.image" title="#{date}"/>

(which would not work inside repeating components like UIData)



来源:https://stackoverflow.com/questions/2371329/jsf-convert-dates-for-title-attribute

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!