Im trying to create my filename in s3 with month/date format. I dont want May to be printed as 5. It has to be '05' I tried
now().month as Number {format: "00"}
and
now().month as Number {format: "##"}
Both prints 5. not as 05.
<set-variable value="#[now().year ++ '/' ++ now().month as Number {format: "00"}++ '/'++ now().day as Number {format: "##"} ++'/'++ now() as String {format: "yyyyMMdd_HHmmss"} ++".json"]" doc:name="S3-filename" doc:id="ff101e31-4f6c-45f5-9669-a60fbc32204e" variableName="s3filename"/>
Dont's do multiple transformations to date, to number, to string. Transform directly to string. Pay attention that Month is MM (upper case) and minutes are mm (lower case)
https://simpleflatservice.com/mule4/Date_format.html
%dw 2.0
output application/java
---
now() as String {format: "MM"}