简体   繁体   中英

How can I return current date as a 'String' in WSO2

I want to return current date as a String in WSO2. I already tried some methods but none of them works.

I parsed current date in my js file but could not change the type of it from integer to string in output.

var currentDateParse = mc.getProperty("currentDate");

How can I return currentDateParse as a string?

I expect the output of currentDateParse as a string like "2019/05/29-22:42:00"

You need to use casting. Your answer would be String(currentDateParse) .

我认为您可以作为currentDateParse.toString() ,它将起作用。

You can do this via the 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"/>

More: https://docs.wso2.com/display/EI611/Synapse+Message+Context+Properties

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM