how to convert yyyymmdd into mm-dd-yyyy in dataweave

穿精又带淫゛_ 提交于 2019-12-25 07:59:12

问题


I have two string 1 represent date and 2nd time. have to convert same into date format in Mule-dataweave

input :- s1= 20161228(yyyymmdd), s2= 1608(hhmm)

output :- 12-28-2016 16:08:00(mm-dd-yyyy hh:mm:ss) in date format.

Any Help?


回答1:


This should work

%dw 1.0
%output application/java
%var s1= 20161228 // (yyyymmdd), 
%var s2= 1608 //(hhmm)
---
output :  (s1 ++ s2) as :localdatetime {format:"yyyyMMddHHmm"} as :string {format:"MM-dd-yyyy HH:mm:ss"}

Hope this helps.




回答2:


{ "data":payload.date as {format:"MM/DD/YY"}as :string{format:"dd/mm/yy"} }



回答3:


You can convert as given below.

DATUM: input as :localdatetime {format: "yyyymmdd"} as :string {format: "yyyyMMdd"},
DATUM: now as :string {format: "mm-dd-yyyy"}

For more about date formats see the below link.

https://docs.mulesoft.com/mule-user-guide/v/3.8/dataweave-types#dates



来源:https://stackoverflow.com/questions/40299183/how-to-convert-yyyymmdd-into-mm-dd-yyyy-in-dataweave

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!