ZonedDateTime withHour(int hour)
returns a copy of this ZonedDateTime
with the hour-of-day value altered.
withHour
has the following syntax.
public ZonedDateTime withHour(int hour)
The following example shows how to use withHour
.
import java.time.ZonedDateTime; public class Main { public static void main(String[] args) { ZonedDateTime dateTime = ZonedDateTime.now(); ZonedDateTime n = dateTime.withHour(14); System.out.println(n); } }
The code above generates the following result.