1
votes

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.

2

2 Answers

2
votes

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"} 
} ]
0
votes

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