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

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

问题描述

如果 #{myBean.birthdate}java.util.Calendarjava.util.Date 类型,我可以格式化吗这可能在 EL 本身内部使用现有函数,其输出类似于 DateFormatSHORTMEDIUMLONG 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} 输出完整的表单:Wed Jan 19 19:01:42 WIT 2011,我更喜欢简单的输出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)} 代替吗?

Should I use #{formatBean.format(myBean.birthdate)} instead?

推荐答案

使用 .您可以将其嵌套在任何输入和输出组件中.模式规则与 java.text.SimpleDateFormat 相同.

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

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

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