Returns a copy of this LocalTime with the hour-of-day field replaced with the specified hour value.
package com.logicbig.example.localtime;
import java.time.LocalTime;
public class WithHourExample {
public static void main (String... args) {
LocalTime t = LocalTime.of(5, 1, 5, 3000);
System.out.println(t);
LocalTime t2 = t.withHour(20);
System.out.println(t2);
}
}
Output
05:01:05.000003
20:01:05.000003