Developing Apama Applications > Developing Apama Applications in Java > Concept of Time in the Correlator > Getting the current time
Getting the current time
In the correlator, the current time is the time indicated by the most recent clock tick. There are two exceptions to this:
*If you specify the -Xclock option when you start the correlator, the correlator does not generate clock ticks. Instead, you must send time events (&TIME) to the correlator. The current time is the time indicated by the most recent externally generated time event. See Externally generating events that keep time (&TIME events).
*When the correlator is firing a timer, the current time is the timer’s trigger time. See About timers and their trigger times.
The information in the remainder of this topic assumes that the current time is the time indicated by the most recent clock tick.
Use the static method double com.apama.jmon.Correlator.getCurrentTime() to obtain the current time. The value returned by the getCurrentTime() method is the current time represented as seconds since the epoch, January 1st, 1970 in UTC.
In the correlator, 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 public context input queues grow.
When a listener triggers, it causes a call to the listener’s match() method. The correlator executes the entire method before the correlator starts to process another event. Consequently, while the listener is executing a method, time and the value returned by the getCurrentTime() method do not change.
Consider the following code snippet,
double a;
void checkTime() {
   a = Correlator.getCurrentTime();
}
 
// A listener calls the following method some time later
void logTime() {
  System.out.println("a: "+a );
     // The time when checkTime() was called
 
   System.out.println("current time: "+Correlator.getCurrentTime() );
// The time now
}
In this code, a method sets double variable a to the value of getCurrentTime(), which is the time indicated by the most recent clock tick. Some time later, a different listener prints the value of a and the value of getCurrentTime(). The values logged might not be the same. This is because the first use of getCurrentTime() might return a value that is different from the second. If the two listeners have processed the same event, the logged values are the same. If the two listeners have processed different events, the logged values are different.
Copyright © 2013-2015 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.
Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.