Syntax

	dateFormat($pattern, $timeZone)

Description

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.

Parameters

Name Type Description Mandatory Default
pattern String

The pattern in which to format. The following characters are possible:

  • y - year
  • M - month in year
  • d - day in month
  • for other symbols see SimpleDateFormat.
yes
timeZone String / Business Object

The time zone in which to render the value. Accepts a time-zone id string (e.g. "Asia/Tokyo"), the string "system" for the application's configured system time zone, the string "user" for the current user's time zone, or the time zone of a calendar.

no Current user's time zone

Return value

Type: Business Object

A date format which can now be used for parse() or format() calls.

Examples

Format

	dateFormat("dd-MM-yy").format(date(2012, 11, 5))

Output: 05-12-2012

Parse

	dateFormat("dd-MM-yy").parse("04-12-12")

Output: 04.12.2012

Format a calendar in its own time zone

	cal = date(2025, 11, 1).toSystemCalendar();
dateFormat("yyyy-MM-dd", $cal.timeZone()).format($cal.toDate())

Output: 2025-12-01