I am looking to get the current date in a workflow so I can append it to a filename I am writing to a folder.
When I have looked around I can only see how to do it in dataweave but this does not look like it will work in the configuration of other components outside dataweave.
How can I do this?
Thanks
In Mule 3 you can do it easily with DataWeave and assign it to a variable or the payload, though the XML is a little more verbose than MEL expression in the answer by utechtzs.
As an example of how to create a filename with the date and assign the string to a variable:
<dw:transform-message doc:name="Transform Message">
<dw:set-variable variableName="filename"><![CDATA[%dw 1.0
%output application/java
---
"myfile-" ++ (now as :string {format: "yyyyMMddHHmmssSSS"})]]>
</dw:set-variable>
</dw:transform-message>
<logger level="INFO" doc:name="Logger" message="#[flowVars.filename]"/>
In Mule 4 DataWeave replaces MEL in expressions and you can use it directly. Example:
#["myfile-" ++ (now() as String {format: "yyyyMMddHHmmssSSS"})]
Both examples return the same Java string. Example: "myfile-20181117150935499"