dateFormat($pattern, $timeZone)
Constructs a date format with the given pattern for either parse() or format() calls.
See SimpleDateFormat.
By default, the format renders values in the current user's time zone. When a timeZone is given, the value is rendered in that time zone instead. This matters when formatting a calendar value: passing its time zone renders the instant as the day it represents in that zone, avoiding a day/month/year shift when the calendar's time zone differs from the user's time zone.
| Name | Type | Description | Mandatory | Default |
|---|---|---|---|---|
| pattern | String |
The pattern in which to format. The following characters are possible:
|
yes | |
| timeZone | String / Business Object |
The time zone in which to render the value. Accepts a time-zone id string (e.g. |
no | Current user's time zone |
Type: Business Object
A date format which can now be used for parse() or format() calls.
dateFormat("dd-MM-yy").format(date(2012, 11, 5))
Output: 05-12-2012
dateFormat("dd-MM-yy").parse("04-12-12")
Output: 04.12.2012
cal = date(2025, 11, 1).toSystemCalendar();
dateFormat("yyyy-MM-dd", $cal.timeZone()).format($cal.toDate())
Output: 2025-12-01