0

I am facing issue while doing string to time conversion in DataWeave2.0.

I am having string as "1800", my requirement is to convert it into time in HH:MM:SS format. I tried going through Mule docs on DateTime, Time but not able to convert string to Time in required format.

Maddy
  • 11
  • 1
  • 6
  • Need more information on what "1800" will resolve to. Should it be "18:00:00" or maybe "00:30:00"? Also what have you tried? What was the result? Please see the following: https://stackoverflow.com/help/how-to-ask – jerney Nov 27 '18 at 15:30
  • It would be resolved to 18:00:00. I tried with LocalTime {format: "HHmm"} as String {format: "HH:mm:ss"}. Which didn't worked. Another option I can think of is String manipulation but it will only produces the string output. – Maddy Dec 03 '18 at 11:00

1 Answers1

2

Since it doesn't have a time zone it's a LocalTime so you can try:

"1800" as LocalTime {format: "HHmm"} as String {format: "HH:mm:ss"}
Shoki
  • 1,508
  • 8
  • 13
  • Hi, tried with the option you mentioned but it is not yielding the expected result in dwl2.0 – Maddy Dec 03 '18 at 11:03
  • 1
    Hi Shoki, solution you provided is working. Issue is with the values I am getting from the target system is in integer, so I did convert it and then tried with your suggestion. It worked! – Maddy Dec 03 '18 at 12:05