Apama Documentation : Developing Apama Applications : Developing Apama Applications in EPL : Using Correlator Plug-ins in EPL : Using the TimeFormat Event Library
Using the TimeFormat Event Library
 
TimeFormat format functions
TimeFormat parse functions
Format specification for the TimeFormat functions
The TimeFormat event library uses the Time Format plug-in.
The TimeFormat event provides routines to obtain the current time and convert to or from string representations of time.
Internally, the correlator expresses time as seconds since the Unix Epoc (1 Jan 1970, midnight UTC) - this is the form of currentTime and is convenient for performing arithmetic, such as differences between times. For more information on this variable, see currentTime.
To convert from string form to float form, use a parseTime method. To convert from float form to string form, use a format method. Both take a format String, which is a string which describes the string form of the time. For more information, see Format specification for the TimeFormat functions.
The parseTime method is available on the TimeFormat event directly. Or you can pre-compile a pattern and then perform parsing using the compiled pattern. A CompiledPattern object is obtained from the TimeFormat event using one of the compilePattern methods (depending on which time zone the pattern should use by default). The CompiledPattern object can be stored in a monitor variable, as an instance of an event or in a local variable and used by listeners. Re-using a CompiledPattern is more efficient than calling one of the TimeFormat.parseTime methods as the format String only needs to be read and compiled once. Calling parse on the TimeFormat event is equivalent to passing the same format String to generate a CompiledPattern and calling parse on that event. It is also possible to create multiple CompiledPattern events if your application needs to use several different formats for time.
For example, the following will behave the same:
TimeFormat timeFmt := new TimeFormat;

timeFmt.parseTime(pattern, time);
timeFmt.compilePattern(pattern).parseTime(time);
There are also functions to obtain the current system time. getSystemTime() provides an absolute time while getMicroTime() provides a high precision time, which is suitable for high precision relative times (the absolute value of getMicroTime() depends on the host operating system).
Patterns with textual elements operate by default in English, but will instead both produce output and expect input in another language if that has been set in the environment. For example, under Linux, if the correlator is running with the LC_ALL environment variable set to "fr_FR", the format "EEEE dd MMMM yyyy G" produces and expects "jeudi 01 janvier 1970 ap. J.-C." for time 0.0.
When you use the TimeFormat event library you can use the TZ environment variable to select a particular locale to be used by the event library. Specify the value in either of the following formats:
Continent/City
Ocean/Archipelago
For example: TZ=Europe/London. The alternative shortened format will not work correctly. For example, TZ=GB will not be recognized. If you specify something like this, Coordinated Universal Time (UTC) is used instead.
Note:  
For a list of time zones, see Timezone ID Values.
Copyright © 2013-2016 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback