Skip to main content
Version: Java (Groovy)

atMidnight

atMidnight returns an instant for the requested input value at midnight in the specified time zone.

Syntax

atMidnight(instant, timeZone)
atMidnight(dateTime)

Parameters

ParameterTypeDescription
instantInstant

The time to compute the prior midnight for.

timeZoneZoneId

The time zone for which the new value at midnight should be calculated.

dateTimeZonedDateTime

The time to compute the prior midnight for.

Returns

Returns either an Instant or a ZonedDateTime for the prior midnight in the specified time zone.

Examples

datetime = parseInstant("2023-01-01T00:05:00 ET")
mt = timeZone("MT")
datetime_zoned = toZonedDateTime(datetime, mt)

println atMidnight(datetime, mt)
println atMidnight(datetime_zoned)