Extensions.DateTime.FormatDate
Contents
Classification
Name | FormatDate |
Short Description | Returns a formatted time representation of a timestamp as a string. |
Class | Term |
Extension | OTX DateTime Extension |
Group | - |
Exceptions | OutOfBoundsException |
Checker Rules | - |
Standard Compliant | Yes |
OTL Syntax
StringTerm DateTime.FormatDate(IntegerTerm timestamp, StringTerm pattern);
Description
Date format is a term which converts a timestamp in a date format and returns as a string. If no custom format is given, the ISO 8601 conform date output shall be formatted equivalent to the custom pattern:
yyyy-MM-dd'T'HH:mm:ss'.'SSSZ
Where "T" is the time designator and "." is a separator for the following millisecond portion. The pattern is language independent. The currently set locale does not influence the output.
Results from FormatDate should not be used for test logic, only for user representations, because exchangeability cannot be guaranteed across different run time systems (e.g. ERA, time zone)!
The format pattern rules are analogous to the rules given for the class java.text.SimpleDateFormat as specified by the Java™ 2 Platform Standard Ed. 6.
The following table gives an overview of the decoding of the format patterns.
Specifier(s) | Meaning | Presentation | Example |
G | Era | Text (localized) | AD |
yy, yyyy | Year (two digits / four digits) | Number | 11, 2011 |
M, MM | Month in year (without / with leading zero) | Number | 9, 09 |
MMM, MMMM | Month in year (short form / long form) | Text (localized) | Jan, January |
d, dd | Day in month (without / with leading zero) | Number | 3, 09 |
D | Day in year | Number | 304 |
F | Day of week of month | Number | 3 |
E, EEEE | Day of week (short form / long form) | Text (localized) | Wed, Wednesday |
h, hh | Hours, 1-12 count (without / with leading zero) | Number | 7, 07 |
H, HH | Hours, 0-23 count (without / with leading zero) | Number | 7, 07 |
m, mm | Minutes (without / with leading zero) | Number | 2, 02 |
s, ss | Seconds (without / with leading zero) | Number | 4, 04 |
S, SS, SSS | Milliseconds (without / with leading zeros) | Number | 357, 04, 002 |
w, W | Week in year / Week in month | Number | 34, 3 |
a | AM/PM designator | Text (localized) | AM |
z, zzzz | Time zone (short form / long form) | Text (localized) | CET, Central European Time |
Z | RFC 822 timezone (timeshift to GMT) | Text | +0100 |
If the timestamp value is negative, the OutOfBoundsException exception will be thrown.
Return Value
The Term returns the value, see table below.
In OTX, Terms are categorized according to its return data type!
Data Type | Description |
String | Date in the form according to ISO8601 or as specified. |
Properties
Name | Data Type | Class | Default | Cardinality | Description |
Timestamp | Integer | Term | - | [1] | This property specifies a date as a time stamp, which is interpreted as the number of milliseconds elapsed since January 1 1970 00:00:00 UTC. |
Pattern | String | Term | - | [0..1] | This feature can represent time in the desired format. |
OTL Examples
/// Local Declarations
String CurrentTime;
/// Flow
CurrentTime = DateTime.FormatDate(DateTime.GetTimestamp(), null);