Reputation: 21
I am converting string "11232017"
(mmddyyyy) into date format in dataweave. If I give the output as json or java, it is converting correctly but application/xml is converting it into yyyy-mm-dd.
code:
%output application/xml
%var a ="12182013"
k:((a as :date {format : "MMddyyyy"} )
Upvotes: 1
Views: 724
Reputation: 172
For printing in json or xml it is always better to put it in string format not the Date object. You can either convert your string to date then again date to string using required format or have your string with the required format.
Upvotes: 1
Reputation: 51
I am getting the date as per MM/dd/yyy with below expression:
%dw 1.0
%output application/xml
---
{
data: {
value: payload as :date {format: "MMddyyyy" } as :string {format: "MM/dd/yyyy"}
}
}
Upvotes: 2