LocalDateTime withHour(int hour)
returns a copy of this LocalDateTime
with the hour-of-day value altered.
withHour
has the following syntax.
public LocalDateTime withHour(int hour)
The following example shows how to use withHour
.
import java.time.LocalDateTime; /*from w ww . j a v a2s . com*/ public class Main { public static void main(String[] args) { LocalDateTime a = LocalDateTime.of(2014, 6, 30, 12, 01); LocalDateTime t = a.withHour(12); System.out.println(t); } }
The code above generates the following result.