Search code examples
javamuledataweavemule-esbmule4

mule4 date format parsing issue, when parsing 2019-02-27T15:43:38.38 in dataweave 2.0 Unable to parse 'T'


I am trying to format current time to yyyy-mm-dd'T'HH:59:59 but in dataweave 2.0 getting below exception for 'T'.

Below is my dataweave code:

StopDate: now() as String{format: 'yyyy-mm-dd'T'HH:59:59'}

Exception

Message : "org.mule.weave.v2.parser.exception.ParseException: Unable to resolve variable T {StopDate: (currentTimeStamp) as String{format: 'yyyy-mm-dd'T'HH:59:59'}}), ^" evaluating expression: "%dw 2.0

I am new to Mule4, please guide


Solution

  • It is because you are using single quotes ' ' within single quotes.

    You can either change it so they are single quotes within double quotes:

    {StopDate: (currentTimeStamp) as String{format: "yyyy-mm-dd'T'HH:59:59"}}
    

    Or escape the quotes:

    {StopDate: (currentTimeStamp) as String{format: 'yyyy-mm-dd\'T\'HH:59:59'}}