我的输入是.csv
格式文件,其出生日期列包含
Aug-03-2015
我想将此coloumn更改为日期(如果不可能,至少是另一个字符串)格式,如下所示
03-08-2015
。 尝试了RyanCarter建议的逻辑。我现在尝试使用
Birthday:$.DOB as :date {format : "MMM-dd-yyyy"} as :string {format: "dd/MM/yyyy"}
其中DOB是.csv输入中的字符串列。但是我得到了以下例外。
Message : Exception while executing:
DOB:$.DOB as :date {format : "MMM-dd-yyyy"} as :string {format: "dd/MM/yyyy"}
^
Cannot coerce a :string to a :date, caused by :Text 'NOV-03-1992' could not be parsed at index 0
Type : com.mulesoft.weave.mule.exception.WeaveExecutionException
Code : MULE_ERROR--2
********************************************************************************
Exception stack is:
1. Cannot coerce a :string to a :date, caused by :Text 'NOV-03-1992' could not be parsed at index 0
(com.mulesoft.weave.model.values.coercion.exception.UnsupportedTypeCoercionException)
com.mulesoft.weave.model.values.coercion.LocalDateTypeCoercionValue:30 (null)
2. Exception while executing:
DOB:$.DOB as :date {format : "MMM-dd-yyyy"} as :string {format: "dd/MM/yyyy"}
^
Cannot coerce a :string to a :date, caused by :Text 'NOV-03-1992' could not be parsed at index 0 (com.mulesoft.weave.mule.exception.WeaveExecutionException)
com.mulesoft.weave.mule.WeaveMessageProcessor$WeaveOutputHandler:166 (null)
********************************************************************************
Root Exception stack trace:
com.mulesoft.weave.model.values.coercion.exception.UnsupportedTypeCoercionException: Cannot coerce a :string to a :date, caused by :Text 'NOV-03-1992' could not be parsed at index 0
答案 0 :(得分:1)
使用日期格式转换为日期格式,然后使用第二种日期格式返回字符串:
varOutput: 'Aug-03-2015' as :date {format : "MMM-dd-yyyy"} as :string {format: "dd/MM/yyyy"}