ISO8601 Date response #641

Closed
opened 2025-12-29 15:29:34 +01:00 by adam · 3 comments
Owner

Originally created by @tyurtyubek on GitHub (Oct 29, 2024).

How to return ISO8601 Date from __admin/mappings with Z in the end like
"signed_at": "2024-10-29T08:40:18.510383Z"
always got in such format
"2024-10-29T21:51:06+02:00"

Originally created by @tyurtyubek on GitHub (Oct 29, 2024). How to return ISO8601 Date from __admin/mappings with Z in the end like `"signed_at": "2024-10-29T08:40:18.510383Z"` always got in such format `"2024-10-29T21:51:06+02:00"`
adam added the question label 2025-12-29 15:29:34 +01:00
adam closed this issue 2025-12-29 15:29:34 +01:00
Author
Owner

@StefH commented on GitHub (Oct 31, 2024):

Please provide your full code or json mapping.

@StefH commented on GitHub (Oct 31, 2024): Please provide your full code or json mapping.
Author
Owner

@StefH commented on GitHub (Nov 1, 2024):

Just use "yyyy-MM-ddTHH:mm:ss.fffffffZ" as custom formatter.

Like:

"signed_at": "{{Format signed_at \"yyyy-MM-ddTHH:mm:ss.fffffffZ\"}}"

@StefH commented on GitHub (Nov 1, 2024): Just use `"yyyy-MM-ddTHH:mm:ss.fffffffZ"` as custom formatter. Like: ``` json "signed_at": "{{Format signed_at \"yyyy-MM-ddTHH:mm:ss.fffffffZ\"}}" ```
Author
Owner

@tyurtyubek commented on GitHub (Nov 2, 2024):

Thank you! I tried to follow a similar approach. I’m attaching some code as an example.
{ "Request": { "Path": { "Matchers": [ { "Name": "RegexMatcher", "Pattern": "/api/test", "IgnoreCase": true } ] }, "Methods": [ "POST" ] }, "Response": { "StatusCode": 200, "BodyAsJson": { "data": { "eta": "{{DateTime.UtcNow}}", "signed_at": "{{String.Format (DateTime.UtcNow) \"yyyy-MM-ddTHH:mm:ss.fffffZ\"}}", "signed_at2": "{{String.Format (DateTime.UtcNow) \"yyyy-MM-ddTHH:mm:ss.fffffffZ\"}}", "signed_atZExample": "{{String.Format (DateTime.UtcNow) \"yyyy-MM-ddTHH:mm:ss.fffffffZ\"}}Z" } }, "UseTransformer": true, "UseTransformerForBodyAsFile": true, "Headers": { "Content-Type": "application/json" } } }

and the results is
{ "data": { "eta": "2024-11-02T15:12:15.802873+02:00", "signed_at": "2024-11-02T15:12:15.80502+02:00", "signed_at2": "2024-11-02T15:12:15.806856+02:00", "signed_atZExample": "2024-11-02T13:12:15.8086470ZZ" } }

@tyurtyubek commented on GitHub (Nov 2, 2024): Thank you! I tried to follow a similar approach. I’m attaching some code as an example. `{ "Request": { "Path": { "Matchers": [ { "Name": "RegexMatcher", "Pattern": "/api/test", "IgnoreCase": true } ] }, "Methods": [ "POST" ] }, "Response": { "StatusCode": 200, "BodyAsJson": { "data": { "eta": "{{DateTime.UtcNow}}", "signed_at": "{{String.Format (DateTime.UtcNow) \"yyyy-MM-ddTHH:mm:ss.fffffZ\"}}", "signed_at2": "{{String.Format (DateTime.UtcNow) \"yyyy-MM-ddTHH:mm:ss.fffffffZ\"}}", "signed_atZExample": "{{String.Format (DateTime.UtcNow) \"yyyy-MM-ddTHH:mm:ss.fffffffZ\"}}Z" } }, "UseTransformer": true, "UseTransformerForBodyAsFile": true, "Headers": { "Content-Type": "application/json" } } }` and the results is `{ "data": { "eta": "2024-11-02T15:12:15.802873+02:00", "signed_at": "2024-11-02T15:12:15.80502+02:00", "signed_at2": "2024-11-02T15:12:15.806856+02:00", "signed_atZExample": "2024-11-02T13:12:15.8086470ZZ" } }`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#641