如何使应用程序中的日期字段独立于系统时区?
How to make date fields in app independent of system timezone?
我有自由风格的应用程序,我在 XML table 中使用日期字段。问题是,如果我更改系统的日期时区(我使用的是 Windows 10),它也会更改我应用程序中字段的日期和时间。
我想要实现的是,独立于我的系统时区,我的应用程序中的 date/time 个字段应该保持不变,它不应该随着我的系统时区而改变。
有人做到了吗?提前致谢。
您需要在数据绑定中添加类型 sap.ui.model.type.Date
或 sap.ui.model.odata.type.DateTime
并指定格式选项 UTC
等于 true
.
<ObjectListItem
number="{
path: 'YourProperty',
type: 'sap.ui.model.type.Date',
formatOptions: {
pattern: 'dd.MM.yyyy',
UTC: true
}
}"
/>
参考:How to handle Edm:DateTime form OData interface in SAPUI5 correct?.
我有自由风格的应用程序,我在 XML table 中使用日期字段。问题是,如果我更改系统的日期时区(我使用的是 Windows 10),它也会更改我应用程序中字段的日期和时间。
我想要实现的是,独立于我的系统时区,我的应用程序中的 date/time 个字段应该保持不变,它不应该随着我的系统时区而改变。
有人做到了吗?提前致谢。
您需要在数据绑定中添加类型 sap.ui.model.type.Date
或 sap.ui.model.odata.type.DateTime
并指定格式选项 UTC
等于 true
.
<ObjectListItem
number="{
path: 'YourProperty',
type: 'sap.ui.model.type.Date',
formatOptions: {
pattern: 'dd.MM.yyyy',
UTC: true
}
}"
/>
参考:How to handle Edm:DateTime form OData interface in SAPUI5 correct?.