在 dataweave 中将时区从未定义更改为 utc

mac*_*aco 2 anypoint-studio dataweave mulesoft

我有一个简单的日期/时间字符串(欧洲当地夏季/冬季时间),我想转换为 UTC。

我收到的日期看起来像这样

{"message": "2021-05-01 15:39"}
Run Code Online (Sandbox Code Playgroud)

但是像这样使用 LocalDateTime

(payload.message as LocalDateTime  {format: "yyyy-MM-dd HH:mm"}  >> "UTC")
Run Code Online (Sandbox Code Playgroud)

将提供“2021-05-01T 15 :49:00Z” - 虽然正确(分别是我想要的),但它应该是“2021-05-01T 13 :49:00Z”。

ale*_*led 5

一种解决方案是手动添加时区:

%dw 2.0
output application/json
var value={"message": "2021-05-01 15:39"}
---
(value.message ++ " CET") as DateTime  {format: "yyyy-MM-dd HH:mm zz"}  >> "UTC"
Run Code Online (Sandbox Code Playgroud)

输出:

"2021-05-01T13:39:00Z"
Run Code Online (Sandbox Code Playgroud)