[英]Mule Dataweave Date Time Conversion from Full to Short
我正在尝试从以下格式转换此datetime字符串:
'Wed, 09 Aug 2017 20:16:59 +0000'
采用这种格式:
'08092017'
我正在使用数据编织。 这是我的代码:
order-date:payload.order.date_created
as :localdatetime {format: "E, dd M yyyy hh:mm:ss Z"}
as :string {format: "MMddyyyy"},
我仍然收到错误-无法将:string强制转换为:localdatetime,原因是:Text'Wed,2017 Aug 08 20:16:59 +0000'无法在索引8处解析
索引8出现在时区偏移量上,但是根据Java文档,时区被指定为大写Z
如果有人从Google偶然发现此内容...我的格式不正确。 这是更正的版本:
order-date:payload.order.date_created
as :localdatetime {format: "E, dd MMM yyyy HH:mm:ss Z"}
as :string {format: "MMddyyyy"},
您应该能够使用dataweave日期格式轻松地做到这一点。 在这里,您首先需要将其转换为本地日期时间,然后再转换为您希望转换为的日期格式。 提供一些来自Mulesoft文档的日期格式转换示例{date:{date1:normalize(“ 26-JUL-16”)as:date {format:“ d-MMM-yy”} as:string {format:“ yyyy-MM -dd“},date2:normalize(” 26 / JUL / 16“)as:date {format:” d-MMM-yy“} as:string {format:” yyyy-MM-dd“},date3:normalize( “ 26.JUL.16”)as:date {format:“ d-MMM-yy”} as:string {format:“ yyyy-MM-dd”}}}
请阅读以下链接,以进一步了解日期格式。
https://docs.mulesoft.com/mule-user-guide/v/3.8/dataweave-examples#parse-dates-with-different-separators https://docs.mulesoft.com/mule-user-guide/v /3.8/dataweave-operators#date-time-operations
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.