Developing Apama Applications > Apama EPL Reference > Variables > Provided variables > currentTime
currentTime
Purpose
The currentTime variable is a read-only float global variable that contains a timestamp value with the current time and date as read from the correlator’s clock. Timestamps are encoded as the number of seconds and fractional seconds elapsed since midnight, January 1, 1970 UTC and do not have a time zone associated with them.
The current time is the time indicated by the most recent clock tick. Use the currentTime variable to obtain the current time. The value of the currentTime variable is always changing to reflect the correlator’s current time.
If you have multiple contexts, it is possible for the current time to be different in different contexts. A particular context might be doing so much processing that it cannot keep up with the time ticks on its queue. In other words, if contexts are mostly idle, then they would all have the same current time.
In a context, the current time is never the same as the current system time. In most circumstances it is a few milliseconds behind the system time. This difference increases when the context’s input queue grows.
When a listener executes an action, it executes the entire action before the correlator starts to process another event. Consequently, while the listener is executing an action, time and the value of the currentTime variable do not change. Consider the following code snippet,
float a;
action checkTime() {
   a := currentTime;
}
// ... Lots of additional code
// A listener calls the following action some time later
action logTime() {
   log a.toString(); // The time when checkTime was called
   log currentTime.toString(); // The time now
}
In this code, an event listener sets float variable a to the value of currentTime, which is the time indicated by the most recent clock tick. Some time later, a different event listener logs the value of a and the value of currentTime. The values logged might not be the same. This is because the first use of currentTime might return a value that is different from the second use of currentTime. If the two event listeners have processed the same event, the logged values are the same. If the two event listeners have processed different events, the logged values are different.
The correlator maintains a clock that advances at a fixed interval (default) of 0.1 seconds. The clock does not advance while an event is being processed.
Copyright © 2013 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or Terracotta Inc., San Francisco, CA, USA, and/or Software AG (Canada) Inc., Cambridge, Ontario, Canada, and/or, Software AG (UK) Ltd., Derby, United Kingdom, and/or Software A.G. (Israel) Ltd., Or-Yehuda, Israel and/or their licensors.