小编Tot*_*Tot的帖子

f:convertDateTime 返回错误的日期和时间

我有一个数据库表,其中包含 DATE 类型的字段,我想以“dd.mm.yyyy hh:mm:ss”格式在用户界面上显示它。我使用 Hibernate 查询获取它并使用以下方法转换它:

<f:convertDateTime pattern="dd.mm.yyyy hh:mm:ss" />
Run Code Online (Sandbox Code Playgroud)

但结果并不是我所期望的。

例如:

8.6.2014 03:00:00 (from the DB)  -> 08.00.2014 12:00:00 (in the user interface)
15.6.2014 12:00:00 (from the DB) -> 15.00.2014 12:00:00 (in the user interface)
Run Code Online (Sandbox Code Playgroud)

我在 web.xml 中添加了

<context-param>
        <param-name>javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</param-name>
        <param-value>true</param-value>
    </context-param>
Run Code Online (Sandbox Code Playgroud)

我的时区是 UTC+02:00

先谢谢您的帮助。

oracle datetime hibernate date

1
推荐指数
1
解决办法
3964
查看次数

标签 统计

date ×1

datetime ×1

hibernate ×1

oracle ×1