I am passing inputDate : 2017-06-27 16:46:36 And
I want to convert format to 27-June-2017
Using Expression Component
I am trying this
flowVars.inputDate = new org.mule.el.datetime.DateTime(new Date(flowVars.inputDate),"yyyy-MM-dd HH:mm:ss");
You can use dataweave script for the same in two ways
1:
<dw:transform-message doc:name="Transform Message">
<dw:set-variable variableName="inputDate"><![CDATA[%dw 1.0
%output application/java
---
flowVars.inputDate as :localdatetime {format:'yyyy-MM-dd HH:mm:ss'} as :string {format:'dd-MMMM-yyyy'}]]></dw:set-variable>
</dw:transform-message>
2:
<set-variable variableName="inputDate" value="#[dw("flowVars.inputDate as :localdatetime {format:'yyyy-MM-dd HH:mm:ss'} as :string {format:'dd-MMMM-yyyy'}")]" doc:name="Variable"/>
Hope this helps.
You can achieve desired result from an expression component
<expression-component doc:name="Expression"><![CDATA[String date_s = "2017-06-27 16:46:36";
java.text.SimpleDateFormat dt = new java.text.SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
java.util.Date date = dt.parse(date_s);
java.text.SimpleDateFormat dt1 = new java.text.SimpleDateFormat("dd-MMMM-yyyy");
flowVars.inputDt = dt1.format(date);]]></expression-component>
<logger message="-------#[flowVars.inputDt]" level="INFO" doc:name="Logger"/>
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.