【问题标题】:how to format month/day for 2 digits in mule4?如何在 mule4 中为 2 位数字格式化月/日?
【发布时间】:2020-05-05 07:06:00
【问题描述】:

我试图在 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"/>

【问题讨论】:

    标签: mule mule-studio mulesoft mule-esb


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 2020-04-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-07
      相关资源
      最近更新 更多