繁体   English   中英

如何在 mule4 中为 2 位数字格式化月/日?

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

我试图以月/日期格式在 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"}

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM