I have a problem with DataWeave 2 transformation. I have:
var parseDate = (dateStr) -> dateStr as DateTime {format: "yyyy-MM-dd"}
But when I am running this code I get:
Caused by: org.mule.runtime.api.el.ExpressionExecutionException: Cannot coerce String (2019-03-26) to DateTime, caused by: Text '2019-03-26' could not be parsed: Unable to obtain ZonedDateTime from TemporalAccessor: {},ISO resolved to 2019-03-26 of type java.time.format.Parsed
I am using DateTime cause it is detected as such when creating metadata. But the class itself has LocalDate bookingDate; - the problem is that when I am trying to use LocalDate - I get an error:
DateTime
LocalDate bookingDate;
LocalDate
Unable to resolve reference of: `LocalDate`.
What can I do with this problem? Can I parse it somehow correctly? Or what can I do with the LocalDate problem mentioned above?
As your input string has only the date part, you can use the following DataWeave expression:
var parseDate = (dateStr) -> dateStr as Date {format: "yyyy-MM-dd"}
2.1m questions
2.1m answers
60 comments
57.0k users