I have a request coming as below format
{
"updatedTime": "Mon Mar 14 15:34:47 NZDT 2022"
}
The response should be converted to "yyyy-MM-dd'T'HH:mm:ss"
{
"updatedTime": "2022-03-14'T'15:34:47"
}
I also referred to Mule docs https://docs.mulesoft.com/dataweave/2.3/dataweave-cookbook-format-dates. Any thoughts? Thanks
Using Mule4, Dataweave 2.0
You should use the patterns characters in the documentation link you shared and construct the pattern for the whole date. You can also search for examples on the Java time package patterns, which are the ones in which DataWeave date/time patterns are based on.
The ones that perhaps are not obvious are to use patter zz
for the timezone and eee
for the localized day name.
%dw 2.0
output application/json
---
{
updatedTime: payload.updatedTime
as DateTime { format: "eee MMM dd HH:mm:ss zz yyyy" }
as LocalDateTime
}