hourOfDay
hourOfDay returns an int representing the hour of the input date-time. Hours are from 0-23, with times between midnight and 1AM on a given day returning the hour 0.
Note
On days when daylight savings time events occur, results may be different from what is expected based upon the local time. For example, on daylight savings time change days, 9:30AM may be earlier or later in the day based upon if the daylight savings time adjustment is forwards or backwards.
Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
| instant | Instant | The time for which to find the hour of the day. |
| timeZone | ZoneId | The time zone to use when interpreting the date-time. |
| dateTime | ZonedDateTime | The zoned date-time for which to find the hour of the day. |
| asLocalTime | boolean | Set this parameter to
On non-DST days, the result is the same regardless of the value of |
| localDateTime | LocalDateTime | The local date-time for which to find the hour of the day. |
| localTime | LocalTime | The local time for which to find the hour of the day. |
Returns
Returns a 0-based int value of the hour of the day.