ZonedDateTime withHour(int hour) example
Description
ZonedDateTime withHour(int hour)
returns a copy of this ZonedDateTime
with the hour-of-day value altered.
Syntax
withHour
has the following syntax.
public ZonedDateTime withHour(int hour)
Example
The following example shows how to use withHour
.
import java.time.ZonedDateTime;
/*from w w w . j a v a 2 s . com*/
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.