0

I have the following string 20170912113456 and i want to convert it to this format 2017/09/12 11:34:56 using Dataweave Mule. Any ideas about how to do it ?

2 Answers 2

1

I would recommend first converting your input date string into a Dataweave localdatetime object. Then you can output the date object back to a string of any format.

%dw 1.0
%output application/json
---
formattedDate: flowVars.date as :localdatetime{format: "yyyyMMddHHmmss"} as :string{format:"yyyy/mm/dd HH:mm:ss"}

If you interested in learning the inner-working check out my converting string dates to Java Date Objects in Mule tutorial, https://youtu.be/XqI_Kii9RzA

Sign up to request clarification or add additional context in comments.

Comments

0

You can try few things like formatting to data and then to string based on below example.

myDate: ((payload as :string) as :date {format: "yyyyMMdd"}) as :string {format: "MM-dd-yyyy"}

For a better understanding the Date Time operations please go through below link.

https://docs.mulesoft.com/mule-user-guide/v/3.8/dataweave-operators#date-time-operations

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.