Developing Apama Applications > Developing Apama Applications in EPL > Using Correlator Plug-ins in EPL > Using the Time Format plug-in > Time Format plug-in compile pattern functions
Time Format plug-in compile pattern functions
The compile pattern functions return a time-parser object of type chunk that you can specify in multiple calls to the parseTimeFromPattern()function. Reusing a time-parser object is significantly more efficient than providing the same time pattern (format) in multiple calls to parse functions.
Usage
chunk compilePattern(string format)
chunk compilePatternUTC(string format)
chunk compilePatternWithTimeZone(string format, string name)
Usage description
format
String that specifies a set of instructions for parsing a time/date object.
name
String that specifies the name of a time zone.
Purpose
The compilePattern() function returns a time-parser object that can generate the time as a float value that corresponds to the local date/time string to be parsed.
The compilePatternUTC() function returns a time-parser object that can generate the time as a float value that corresponds to the UTC date/time string to be parsed.
The compilePatternWithTimeZone() function returns a time-parser object that can generate the time as a float value that corresponds to the date/time string to be parsed, in the specified timezone.
Examples
The following example shows how you can specify the chunk returned by a compilePattern() function in multiple calls to parseTimeFromPattern():
chunk compiled:=timeMgr.compilePattern(pattern);
t1:=parseTimeFromPattern(compiled, time1);
t2:=parseTimeFromPattern(compiled, time2);
t3:=parseTimeFromPattern(compiled, time3);
t4:=parseTimeFromPattern(compiled, time4);
When you call a compilePattern() function and then the parseTimeFromPattern() function, the result is the same as calling one of the parse functions. The advantage of calling a compilePattern() function and then parseTimeFromPattern() is that it is faster. For example:
timeMgr.parse("yyyy.MM.dd G 'at' HH:mm:ss", "1996.07.10 AD at 15:08:56")
See also Midnight and noon.
If you use this pattern many times, it is faster to call compilePattern(), as follows:
Chunk c := timeMgr.compilePattern("yyyy.MM.dd G 'at' HH:mm:ss")
timeMgr.parseTimeFromPattern(c,"1996.07.10 AD at 15:08:56")
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.