在JSF中格式化日期输出 [英] Format Date output in JSF

查看:208
本文介绍了在JSF中格式化日期输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果#{myBean.birthdate}java.util.Calendarjava.util.Date类型,我是否可以使用现有函数在EL自身内部格式化此格式,其输出类似于DateFormatMEDIUMLONG abd FULL输出类型?

If #{myBean.birthdate} is of java.util.Calendar or java.util.Date type, can I possibly format this inside the EL itself using an existing function perhaps, with the output of like the one produced by the DateFormat's SHORT, MEDIUM,LONG abd FULL output type?

我没有输出#{myBean.birthdate}的完整表格: 2011年1月19日星期三19:01:42 ,我只喜欢简单输出 2011年1月19日 >.

Instead of outputting the complete form for the #{myBean.birthdate}: Wed Jan 19 19:01:42 WIT 2011, I just prefer a simple output of Jan 19, 2011.

我应该改用#{formatBean.format(myBean.birthdate)}吗?

推荐答案

使用 java.text.SimpleDateFormat 相同.

Use <f:convertDateTime>. You can nest this in any input and output component. Pattern rules are same as java.text.SimpleDateFormat.

<h:outputText value="#{someBean.dateField}" >
    <f:convertDateTime pattern="dd.MM.yyyy HH:mm" />
</h:outputText>

这篇关于在JSF中格式化日期输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆