0

I am unable to use Mulesoft DataWeave to effectively transform a Date to a DateTime. For some reason, Mulesoft is treating the Date as a String.

What can I do to fix this issue and convert the date properly? The format I am attempting to go from is yyyy-mm-dd to mm/dd/yyyy hh:mm:ss.

Error:

Cannot coerce a :string to a :datetime, caused by :Text '2019-03-08' could not be parsed at index 2.

DataWeave

DateCustomFieldRef__custentity_icims_legacy_f_next_renewal: flowVars.SalesforceAccount.Contract_End_Date__c as :datetime {format: "dd/MM/yyyy HH:mm:ss"}

In the example above, flowVars.SalesforceAccount.Contract_End_Date__c is a DATE, and DateCustomFieldRef__custentity_icims_legacy_f_next_renewal is a Date_time in NetSuite.

Coova
  • 1,818
  • 5
  • 36
  • 63

1 Answers1

1

As per Mule Type Coercion Table :date to :date time Coercion not possible. You have to append time something like below to get expected result. As time will be default 00:00:00

%dw 1.0
%output application/java
---
("2017-02-15" ++ "00:00:00" )as :localdatetime  {format: "yyyy-MM-ddHH:mm:ss"} as :string {format: "dd/MM/yyyy HH:mm:ss"}

HTH

AnupamBhusari
  • 2,395
  • 2
  • 14
  • 22