在 JSF 中格式化日期输出 [英] Format Date output in JSF
问题描述
如果 #{myBean.birthdate}
是 java.util.Calendar
或 java.util.Date
类型,我可以格式化吗这可能在 EL 本身内部使用现有函数,其输出类似于 DateFormat
的 SHORT
、MEDIUM
、LONG
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屋!