如何在 mule4 中为 2 位数字格式化 month/day?

how to format month/day for 2 digits in mule4?

我正在尝试使用 month/date 格式在 s3 中创建我的文件名。 我不想将 May 打印为 5。它必须是“05” 我试过了

  now().month as Number {format: "00"}

now().month as Number {format: "##"}

两者都打印 5。不像 05.

<set-variable value="#[now().year ++ '/' ++ now().month as Number {format: &quot;00&quot;}++ '/'++ now().day as Number {format: &quot;##&quot;} ++'/'++ now() as String {format: &quot;yyyyMMdd_HHmmss&quot;} ++&quot;.json&quot;]"  doc:name="S3-filename" doc:id="ff101e31-4f6c-45f5-9669-a60fbc32204e" variableName="s3filename"/>

不要对日期、数字、字符串进行多次转换。直接转换为字符串。注意月份是MM(大写),分钟是mm(小写)

https://simpleflatservice.com/mule4/Date_format.html

%dw 2.0
output application/java
---
now() as String {format: "MM"}