Search code examples
simpledateformatiso8601mule-el

How do I parse an ISO 8601 date into a Mule flow variable?


I have an ISO 8601 date as a string and I need to parse it into a date and store it as a Mule flow variable. An example of the string is 2016-08-01T15:03:00.043-04:00 and I have tried various format strings using DateUtils.getDateFromString and SimpleDateFormat, but have not been successful. This is the CE version of Mule so Dateweave/Datamapper are out of the question.

Can anyone suggest how I can parse this date?

Thanks,

David.


Solution

  • Please try using below command:

    [dateString = new Date().toString();

    payload = new org.mule.el.datetime.DateTime(dateString, 'yyyy MM dd');]

    Reference URL: https://docs.mulesoft.com/mule-user-guide/v/3.6/mule-expression-language-date-and-time-functions