Dates and Times
dateFormat
Formats Java Date or TemporalAccessor values.
Example output:
2026-05-15
Predefined date styles (no explicit locale):
Locale and timezone:
Include time:
dateTimeFormat
Formats date values as timestamps using the output format.
Input can be any either Long (milliseconds since epoch) or String (date/time string in a format specified by the input parameter).
Syntax:
Usage:
Input and output format parameters are any of:
basicIsoDate: DateTimeFormatter.BASIC_ISO_DATE, e.g.,20190903epochMillis: milliseconds since Unix epoch started, e.g.,1567441719278epochSeconds: seconds since Unix epoch started, e.g.,1567441719isoDateTime: DateTimeFormatter.ISO_DATE_TIME, e.g.,2019-09-03T00:28:39.279+08:00[Asia/Singapore]isoDate: DateTimeFormatter.ISO_DATE, e.g.,2019-09-03+08:00isoInstant: DateTimeFormatter.ISO_INSTANT, e.g.,2019-09-02T16:28:39.280ZisoLocalDateTime: DateTimeFormatter.ISO_LOCAL_DATE_TIME, e.g.,2019-09-03T00:28:39.278isoLocalDate: DateTimeFormatter.ISO_LOCAL_DATE, e.g.,2019-09-03isoLocalTime: DateTimeFormatter.ISO_LOCAL_TIME, e.g.,00:28:39.275isoOffsetDateTime: DateTimeFormatter.ISO_OFFSET_DATE_TIME, e.g.,2019-09-03T00:28:39.278+08:00isoOffsetDate: DateTimeFormatter.ISO_OFFSET_DATE, e.g.,2019-09-03+08:00isoOffsetTime: DateTimeFormatter.ISO_OFFSET_TIME, e.g.,00:28:39.277+08:00isoOrdinalDate: DateTimeFormatter.ISO_ORDINAL_DATE, e.g.,2019-246+08:00isoTime: DateTimeFormatter.ISO_TIME, e.g.,00:28:39.278+08:00isoWeekDate: DateTimeFormatter.ISO_WEEK_DATE, e.g.,2019-W36-2+08:00isoZonedDateTime: DateTimeFormatter.ISO_ZONED_DATE_TIME, e.g.,2019-09-03T00:28:39.279+08:00[Asia/Singapore]rfc1123DateTime: DateTimeFormatter.RFC_1123_DATE_TIME, e.g.,Tue, 3 Sep 2019 00:28:39 +0800pattern: a custom DateTimeFormatter pattern, e.g., `` ->Tue, 3 Sep 2019 00:28:39 +0800
Otherwise, the default formatter (isoInstant) will be used. The output format option can be specified as a parameter or hash (a.k.a. named parameter).
- The "locale" parameter can be used to select a locale, e.g. "de" or "en_GB". It defaults to the env property
DEFAULT_LOCALE(en-GBby default). This is applied only for output formatting. Input parsing always uses the default. - The "tz" parameter is the time zone to use, e.g. "Europe/Berlin" or "GMT-8:00". It defaults to the env property
DEFAULT_TIMEZONE(UTCby default). This is applied only for output formatting. Input parsing always uses the default.
dateTimeParse
Parses a string into a date/time value (millis since epoch without time zone). Useful when juggling with timezones.
Syntax:
Usage:
For input format parameter see dateTimeFormat.
The default formatter is isoInstant.
The input format option can be specified as a parameter or hash (a.k.a. named parameter).
- The "locale" parameter can be used to select a locale, e.g. "de" or "en_GB". It defaults to the env property
DEFAULT_LOCALE(en-GBby default). - The "tz" parameter is the time zone to use, e.g. "Europe/Berlin" or "GMT-8:00". It defaults to the env property
DEFAULT_TIMEZONE(UTCby default).
now
Formats the current date/time using the same options as dateTimeFormat.
With timezone:
With predefined style: