简体   繁体   中英

Date format conversion on data weave in mule esb

I'm using transform message component to transfer .csv file to another .csv file. input is coming in "YYYY/DD/MM HH:MM:SS" format but I need to transform to "MM/DD/YYYY" format.

You need to parse the string to a Date using the one format then back to string using another format something like so:

%dw 1.0
%output application/csv
---
 [{
someDate:  '2015/10/19 12:00:00' as :localdatetime {format: "yyyy/MM/dd H:mm:ss"}
    as :date {format: "MM/dd/yyyy"} 
} ]

You can also give it a try with this expression

%dw 1.0
%output application/csv
---
formatedDate: |2003-10-01T23:57:59| as :string {format: "MM-dd-yyyy"}

For more date conversion you can refer to mulesoft document.

https://developer.mulesoft.com/docs/dataweave#_changing_the_format_of_a_date

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