With this command in Dataweave 2.0 :
"08:05:30" as DateTime{format: "hh:mm:ss"} as String {format: "hh:mm:ss"}
I have this error :
Unable to obtain ZonedDateTime from TemporalAccessor
How to solve it ? My whole problem is to transform :
"Wed Oct 18 2023 08:05:30 GMT-0000 (GMT)"
to
"2012-10-11T12:30:40-03:00"
I tried :
"Wed Oct 18 2023 08:05:30 GMT-0000 (GMT)" as DateTime{format: 'E MMM dd yyyy hh:mm:ss zXX O'} as String {format: "yyyy-MM-dd'T'hh:mm:ssO"}
Thank you so much !
You are trying to convert a string that contains apparently a time to a Date Time plus Time zone type. Because the input misses the date and time zone the transformation will fail.
Instead convert it to a LocalTime (ie a time without a timezone):
"08:05:30" as LocalTime{format: "HH:mm:ss"} as String {format: "HH:mm:ss"}
Note that I used HH
for the 24 hs format. Using hh
is for the 12 hs am/pm format.
By the way, it is fine if this is just an example but converting to String at the end is just returning a string equal to the input. Not sure if that is intentional.