简体   繁体   English

如何在WSO2中以“字符串”形式返回当前日期

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

I want to return current date as a String in WSO2. 我想在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. 我解析了js文件中的当前日期,但无法在输出中将其类型从整数更改为字符串。

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

How can I return currentDateParse as a string? 如何将currentDateParse返回为字符串?

I expect the output of currentDateParse as a string like "2019/05/29-22:42:00" 我希望currentDateParse的输出像"2019/05/29-22:42:00"这样的字符串

You need to use casting. 您需要使用投射。 Your answer would be String(currentDateParse) . 您的答案将是String(currentDateParse)

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

You can do this via the SYSTEM_DATE property by defining the required format as below. 您可以通过定义以下所需的格式,通过SYSTEM_DATE属性来执行此操作。

<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 更多: https : //docs.wso2.com/display/EI611/Synapse+Message+Context+Properties

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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