Skip to main content
Version: Java (Groovy)

formatDateTime

formatDateTime returns a string representation of a date-time for a specified time zone, formatted as yyyy-MM-ddThh:mm:ss.SSSSSSSSS TZ.

Syntax

formatDateTime(instant, timeZone)
formatDateTime(dateTime)

Parameters

ParameterTypeDescription
instantInstant

The Instant to format as a string.

timeZoneZoneId

The time zone used when formatting the string.

dateTimeZonedDateTime

The time to format as a string.

Returns

The time, formatted as a yyyy-MM-ddThh:mm:ss.SSSSSSSSS TZ string.

Examples

datetime = parseInstant("2022-01-01T00:00:00 ET")

formatted_date = formatDateTime(datetime, timeZone("ET"))
println formatted_date