[英]Unable to coerce a :string to :datetime
I am unable to use Mulesoft DataWeave to effectively transform a Date to a DateTime. 我无法使用Mulesoft DataWeave有效地将Date转换为DateTime。 For some reason, Mulesoft is treating the Date as a String.
由于某些原因,Mulesoft将Date视为字符串。
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 .
我尝试从的格式是yyyy-mm-dd到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.
无法将:string强制转换为:datetime,原因是:Text'2019-03-08'无法在索引2处解析。
DataWeave 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. 在上面的示例中,在NetSuite中, flowVars.SalesforceAccount.Contract_End_Date__c是DATE , DateCustomFieldRef__custentity_icims_legacy_f_next_renewal是Date_time 。
As per Mule Type Coercion Table :date to :date time Coercion not possible. 根据M 类型强制表 :date到datedate不能强制强制。 You have to append time something like below to get expected result.
您必须添加以下类似的时间才能获得预期的结果。 As time will be default 00:00:00
默认时间为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 HTH
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.