0

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?

himanshu
  • 21
  • 2
  • 8
  • http://stackoverflow.com/questions/33075127/converting-to-a-date-format-in-mule-using-dataweave may help you – Aroniaina Oct 28 '16 at 06:38
  • I have done this but will it be able to convert into date?? %dw 1.0 %output application/java %input payload application/json %var Cdate = payload.mdate[4..5] ++ "-" ++ payload.mdate[6..7] ++ "-" ++ payload.mdate[0..3] %var Ctime = payload.mtime[0..1] ++ ":" ++ payload.mtime[2..3] ++ ":00" --- Cdate ++ " " ++ Ctime – himanshu Oct 28 '16 at 07:38

3 Answers3

0

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.

AnupamBhusari
  • 2,395
  • 2
  • 14
  • 22
0
{ "data":payload.date as {format:"MM/DD/YY"}as :string{format:"dd/mm/yy"} }
Baum mit Augen
  • 49,044
  • 25
  • 144
  • 182
veda
  • 10
  • 1
  • 4
0

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

Srinivas
  • 92
  • 3