The Date Class
The Date class provides methods for date formatting and parsing.
Syntax
Date
Methods
Class methods are static methods that do not require an object. The method name is prefixed by the class name.
Name | Description |
---|---|
|
Constructs a Date from the date value; returns a Date instance
representing the value. The value is expected in iso format ("YYYY-MM-DD"). Using the function guarantees that the Date value is constructed correctly without the danger of runtime parse errors due to changing 4GL date formatting or locale settings. |
|
Constructs a Date from value. The parsing is based on the passed format pattern. See Formatting Symbols for Dates. |
|
Formats a Date as a String according to a format specification. The format specification is 4GL-compatible. Returns a string representation of the date. See Formatting Symbols for Dates. |
|
Constructs a Date from the current date value. Returns a Date instance representing the current date. |
Usage
With RTL classes, it is not possible to create and subclass objects. The
new
keyword is not supported.
These static methods do not require a Date object instance. When you invoke the method, it is
prefixed with the Date
class name and the '.'
Formatting symbols
The formatting symbol can use either uppercase or lowercase letters.
Character | Description |
---|---|
dd |
Day of the month as a two-digit integer. |
ddd |
Three-letter English-language abbreviation of the day of the week, for example, Mon, Tue. |
mm |
Month as a two-digit integer. |
mmm |
Three-letter English-language abbreviation of the month, for example, Jan, Feb. |
yy |
Year, as a two-digit integer representing the two trailing digits. |
yyyy |
Year as a four-digit number. |
Examples
The following expression displays today's date in the format "dd mmm yyyy", for example, "10 Jun 2016":
Date.today().format("DD MMM YYYY")
The following expression uses the value of the variable orderline.orders.orderdate to create a valid date for this value in the specified format:
Date.fromIsoValue(orderline.orders.orderdate.isoValue).format("DDD DD MMM YYYY")