K S
K S

Reputation: 85

mulesoft dataweave date formatting issue

input date: "2019-09-11T14:14:00.000-05:00", need output date: "2019-09-11T14:14:00Z"

datawave code -

("noteDateTime": payload.createTimeStamp as LocalDateTime {format:"yyyy-MM-dd'T'HH:mm:ss.SSS-X"} as String {format:"yyyy-MM-dd'T'HH:mm:ss'Z'"})

is giving an output as "2019-09-11T14:01:00.000-05:00"

Upvotes: 1

Views: 172

Answers (1)

machaval
machaval

Reputation: 5059

As I show you in the code just use DateTime and not LocalDateTime as your temporal data does have a TimeZone and your string is already in the correct format so no need to specify any format.

%dw 2.0
output application/json
---
"2019-09-11T14:14:00.000-05:00" as DateTime as String {format:"yyyy-MM-dd'T'HH:mm:ss'Z'"}

Upvotes: 5

Related Questions