monthOfYear
monthOfYear returns the 1-based value for the month of the year for a specified date-time.
Syntax
monthOfYear(instant, timeZone)
monthOfYear(dateTime)
Parameters
| Parameter | Type | Description |
|---|---|---|
| instant | Instant | The date-time from which to return the number of months. |
| timeZone | ZoneId | The time zone. |
| dateTime | ZonedDateTime | The date-time from which to return the number of months. |
Returns
Returns an int value representing the month of the year.
Examples
datetime = parseInstant("2022-01-01T12:34:56 ET")
month = monthOfYear(datetime, timeZone("ET"))
println month