One of the entries on our Xdata server is accepting some datetime values in the json structure.
The client sends iso8601 dates with a trailing Z (ie. "2020-05-05T12.00.00Z") to tell that the value represents a UTC date / time.
It seems that the parser doesn't accept this format (as stated in the doc at https://download.tmssoftware.com/business/xdata/doc/web/literals_in_uri.html ).
Is it on purpose and is there a way to deal with this ?
Best regards,
Jean-Michel
wlandgraf
(Wagner Landgraf)
October 5, 2020, 4:49pm
2
You can enable support for the Z
suffix this way:
uses Bcl.Utils;
...
DefaultTimeZoneMode := TTimeZoneMode.AsLocal;
Note this will not only access the Z
but will also convert the date to local time . If you want the parser to just access the Z
suffix but ignore it as an UTC date, considering it just a local date, use Ignore:
DefaultTimeZoneMode := TTimeZoneMode.Ignore;
1 Like
Wagner,
I'm trying this setting as well, but I do not see any difference in the data I get from my xData rest server.
It seems the default value of DefaultTimeZone is TTimeZoneMode.Error;
When I do a GET from an entity with a datetime field the JSON format shows:
"LastActivityUTC": "2023-02-15T08:31:02"
Setting the
DefaultTimeZone := TTimeZoneMode.AsUtc
or
DefaultTimeZone := TTimeZoneMode.AsLocal
the returned value from server is still missing the trailing 'Z'
"LastActivityUTC": "2023-02-15T08:31:02"
Any hints or suggestions you could share with me? Or maybe point me to some documentation?
Thank you
wlandgraf
(Wagner Landgraf)
February 22, 2023, 1:06pm
4
The DefaultTimeZone
is only used for deserialization of date-time values.
I understand you want to serialize your dates using time zone? In this case, you can use a specific date-time converter:
[JsonConverter(TJsonDateTimeZoneConverter)]
FLastActivityUTC: TDateTime;
1 Like
system
(system)
Closed
February 24, 2023, 1:07pm
5
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.