How to get the formatted current system date and time via WSO2 ESB

Naduni Pamudika
1 min readJul 19, 2018

--

source: https://www.sitepoint.com/suggesting-carbon-with-composer-date-and-time-the-right-way/

From this blog post I am going to tell you how to get current system date in the format you want using WSO2 ESB.

The SYSTEM_DATE property in synapse gives you the current system date.

When doing this you have to use the synapse default scope.

Lets say you want to take the system time in a formatted manner. Then you can use the Property Mediator in WSO2 ESB like this.

<property name="date" expression="get-property('SYSTEM_DATE', 'yyyy-MM-dd')" scope="default"/>

Say you want to get the system date and time in a formatted manner like this.

2018-07-19T10:43:07+00:00

You can do this via the same SYSTEM_DATE property by defining the required format as below.

<property name="date" expression='get-property("SYSTEM_DATE", "yyyy-MM-dd&apos;T&apos;HH:mm:ss.SSSXXX")' scope="default"/>

In this case note that you have to use single quote when calling get-property and inside that you have to use double quotes which is an exceptional case.

Like wise you can define the format you want and access the current system time.

--

--

Naduni Pamudika

Associate Technical Lead @ WSO2 | Graduate from the Department of Computer Science & Engineering, University of Moratuwa