Gopi
Gopi

Reputation: 105

How to parse yyyy-Mm-ddThh:mm:ss format in dataweave mule

I tried expression like below in mule dataweave but I am getting error.

pdate : "2017-06-22T12:45:55" as:datetime{format : "yyyy-Mm-dd'T'hh:mm:ss"} as :string{format: "MM/DD/yyyy"}

Can you please help on this if I missed anything to write.

Upvotes: 1

Views: 1668

Answers (1)

Yevgeniy
Yevgeniy

Reputation: 2694

try this:

%dw 1.0
%output application/json
---
{
    pdate: "2017-06-22T12:45:55" as :localdatetime { format: "yyyy-MM-dd'T'HH:mm:ss" } as :string { format: "MM/dd/yyyy" }
}

changes compared to your version:

  1. replace Mm with MM in first format string, thx @Dai
  2. replace hh with HH in first format string
  3. replace DD with 'dd' in second format string

enter image description here

Upvotes: 1

Related Questions