convert MYSQL date time format to UTC time format in Mule 4

617 Views Asked by At

I have a requirement where I need to format the dateTime value received from MySql db to UTC time in using Mule 4 Dataweave. Example: i/p: 2021-01-20 00:00:00.0 expected o/p: 2021-01-20T00:00:00.000Z.

1

There are 1 best solutions below

0
On BEST ANSWER

What you receive from the Mulesoft Database connector is a Java SQL Date object, not a String, unless the query formats it on the DB. If you want a string representation of it, you need to format it using something like this:

myDate as String {format: "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"}