OffsetDateTime withHour(int hour)
returns a copy of this OffsetDateTime with the hour-of-day value altered.
withHour
has the following syntax.
public OffsetDateTime withHour(int hour)
The following example shows how to use withHour
.
import java.time.OffsetDateTime; 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.