Why...?
It is quite important to sort out the right combination of OData (V2) Data Type / Annotations and SmartControl settings to match the targeted use case perfectly.
In date- and time-related issues it is not always obvious which combination fits the concrete use case best. Below you find a list to understand a bit when to use what.
Usage recommendation
(sorted descending to their importance/frequency of use):
For Dates
Example |
"Dec. 12th, 2020" |
OData Service Metadata |
Edm.DateTime with sap:display-format="Date"
|
UI |
The SmartControls show only the "date" part of the timestamp, independent of the local time zone (e.g. there is no shift of a date when looked at from two different machines in two different timezones). For input, a date picker is offered. |
Real-world sample |
Use this data type for all dates that are globally not shifted, e.g. birthdays (Mr. Gauß was born on Apr. 30th, 1777, independent if you speak about it in India or America). |
For Time Stamps containing Date and Time
Example |
"Dec. 12th, 2020, 19:22:39" |
OData Service Metadata |
Edm.DateTimeOffset
|
UI |
The SmartControls show data and time in local user time zone. For input, a DateTime picker is offered. |
Real-world sample |
Use this data type for timestamps that should be shown in the users timezone, e.g. build timestamps, creation timestamps (a car production was completed at Dec. 12th, 10:21:32 GMT) or the beginning of a virtual meeting (here, every user wants to see "her" specific start timestamp). |
For Time Stamps containing Date and Time, displayed in their local representation
Example |
"Jun. 3rd, 2019, 10:00:00" |
OData Service Metadata |
Edm.DateTime
|
UI |
Currently not well supported by the SAPUI5 SmartControls.
A work around could be to use a combination of two fields, one typed as Edm.DateTime with sap:display-format="Date" and one typed as Edm.Time. |
Real-world sample |
Use this data type to present a timestamp in its "local" representation and not recalculated to the user's timezone, e.g. for arrival of a plain on a certain airport (where the user wants to see the local date/time, not recalculated to her current time zone). |
For Times
Example |
"19:33:49" |
OData Service Metadata |
Edm.Time
|
UI |
The SmartControls show the time as given by the service. For input, a time picker is offered. |
Real-world sample |
Use this data type to express a certain time on a fixed date or on no specific date, e.g. start and end times for sessions on a onsite event. |
Conclusion
With the above mentioned hints it might got clearer which data type needs to be taken in the OData service. But there is even more! For further details and hints about how the functions and features of the UI5 Smart Controls can be leveraged and wich specific OData features are supported, please see also
the "Smart Controls" area in the UI5 documentation and the respective API reference pages of the controls (
SmartField,
SmartFilterBar,
SmartTable,
SmartChart).