在我的 Web 应用程序中,我使用 Hibernate 检索数据并将其显示在 RichFaces 数据表中。
在我的 MySQL 表中有一个“日期”类型的字段。当我将此字段打印到我的 Bean 中的日志时,它会显示数据库中的正确日期(例如 2010-04-21)。但在 rich:dataTable 中显示如下:
2010 年 4 月 20 日
所以有1天的差异!
我添加了“f:convertDateTime”转换器并将“type”属性设置为“both”以显示时间。所以现在它显示:
2010 年 4 月 20 日晚上 10:00:00
我使用过的“f:convertDateTime”代码:
<f:convertDateTime locale="locale.US" type="both" dateStyle="short"/>
所以看起来 f:convertDateTime 做了一段时间的梦,因为 MySQL 表字段中没有时间信息!
我究竟做错了什么?我需要做什么才能显示正确的日期?
谢谢汤姆