Hello all,
how can I print the current time as a string?
using “TimeFormat.format(currentTime, “yyyy-MM-dd’T’HH:mm:ss.SSS’Z’”),” does not work.
Thank you.
Hello,
Please refer to these documentation links to see if they resolve your issue, otherwise please can you provide the full line for reference.
Apama (softwareag.com)
currentTime (softwareag.com)
TimeFormat
Thanks,
Jack
Could you elaborate a bit more on what does happen and what you are looking to achieve? Is Z intended to be a literal letter?
I’ve recently been doing just this with a slighht variance with the seconds.
constant string ISO_FORMAT := "yyyy-MM-dd'T'HH:mm:ss.SSSXXX";
string now := TimeFormat.format(currentTime, ISO_FORMAT);
This works:
using com.apama.correlator.timeformat.TimeFormat;
monitor MySampleMonitor {
/** Initialize the application */
action onload() {
log "The current time is: " + TimeFormat.format(currentTime, “yyyy-MM-dd’T’HH:mm:ss.SSS’Z’”) at INFO;
}
}
(Be careful copying/pasting that you get basic ascii quote characters and note any kind of smart-quotes.)
And another solution: if you are in Cumulocity and want to get the format Cumulocity is using, there is Util.formatTime():
https://documentation.softwareag.com/pam/10.15.3/en/webhelp/related/ApamaDoc/com/apama/cumulocity/Util.html#formatTime()
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.