Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

dataweave transformation DateTime

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

"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 !

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading