【问题标题】:Java / SAP HYBRIS : Timezone Date Issues in Java/hybris BackofficeJava/SAP HYBRIS:Java/hybris Backoffice 中的时区日期问题
【发布时间】:2021-06-22 17:51:52
【问题描述】:

我正在使用 sap cx 20.03 版

我在日期类型的模型中添加了一个属性。

<attribute qualifier="date" type="java.util.Date" >
<persistence type="property" />
<modifiers optional="true" />
<description>order date</description>
</attribute>

所以,我在日期字段中输入了Tue Jun 08 19:00:00 WEST 2021,保存模型后,该值在数据库中保存为Tue Jun 08 20:00:00 WEST 2021。服务器位于非洲/卡萨布兰卡时区。请解释这种转换是如何发生的!

我需要保存用户选择的日期。 Tue Jun 08 19:00:00 WEST 2021

这是后台级别的配置。

<editorArea:attribute qualifier="date" editor="com.hybris.cockpitng.editor.defaulttime">             
   <editorArea:editor-parameter>
      <editorArea:name>timeFormat</editorArea:name>
      <editorArea:value>short</editorArea:value>
    </editorArea:editor-parameter>
</editorArea:attribute>

【问题讨论】:

    标签: java date hybris


    【解决方案1】:

    你的时区是什么时候?如果它与服务器时区不同,它将与 Backoffice 时区不匹配,因为 Backoffice 通常基于您/浏览器的时区。

    【讨论】:

    • 我正在保存日期。根据我的需要,我在 BO 中有字段日期和时区列表,我将日期格式化为 HH:mm。因此,当用户选择日期和时区时,我想将其保存在数据库中,此时区示例用户选择例如 16:00 和时区 GMT+2,我要保存的值为 16: 00 in GMT + 2 我添加了一个 prepareInterceptor 并设置了用户选择的时区,但他将其转换为他添加了 2 个小时的时间。
    • 我想指出这个日期是在用户选择的时区中,而不是转换它,并且默认情况下没有将它转换为时区服务器,我的情况是非洲/卡萨布兰卡
    • 有什么解决办法吗?
    猜你喜欢
    • 2019-01-31
    • 2020-10-05
    • 1970-01-01
    • 1970-01-01
    • 2020-11-09
    • 1970-01-01
    • 1970-01-01
    • 2011-10-25
    • 1970-01-01
    相关资源
    最近更新 更多