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