OffsetDateTime withHour(int hour) example
Description
OffsetDateTime withHour(int hour)
returns a copy of this OffsetDateTime with the hour-of-day value altered.
Syntax
withHour
has the following syntax.
public OffsetDateTime withHour(int hour)
Example
The following example shows how to use withHour
.
import java.time.OffsetDateTime;
//from www . j a v a 2s. c o m
public class Main {
public static void main(String[] args) {
OffsetDateTime o = OffsetDateTime.now();
OffsetDateTime d = o.withHour(4);
System.out.println(d);
}
}
The code above generates the following result.