简体   繁体   中英

Unable to coerce a :string to :datetime

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM