formatTime()
The strLib.formatTime() system function accepts a TIME value as input and returns a STRING value.
EGL tries the following formats for the conversion, in order. If
a particular format is null, empty, or not valid, EGL moves to the
next:
- The format string provided as a parameter
- strLib.defaultTimeFormat
- The time format in the Java™ locale object (Java™ only)
If all these attempts fail, the return value is null.
Syntax
strLib.formatTime(
aTime TIME? in
[, timeFormat STRING? in] )
returns (result STRING?)
- aTime
- The value to be formatted. The input can be any expression that is assignment compatible with a TIME value, such as the return value of the dateTimeLib.currentTime() system function.
- timeFormat
- Identifies the time format, as described in Date/time masks and format specifiers. You can use a literal, a string variable, or any of the time format constants described in EGL library strLib.
- result
- A STRING value. If aTime is null, or if EGL cannot find a valid format, the function returns a null value.
Example
The following example assumes that it is 12:32 in the afternoon on the West Coast of the U.S. in the summer:
myFormat STRING = "hh 'o''clock' a, zzzz";
result STRING;
result = strLib.formatTime(dateTimeLib.currentTime(),myFormat);
// result is "12 o'clock PM, Pacific Daylight Time"