The accepted answer is good. You can also create your own clock to do this:
Clock clock = Clock.tick(Clock.systemDefaultZone(), Duration.ofHours(1)); LocalDateTime dt = LocalDateTime.now(clock);
This can be a useful option if it is reused, because the clock can be stored in a static variable:
public static final Clock CLOCK = Clock.tick(Clock.systemDefaultZone(), Duration.ofHours(1)); LocalDateTime dt = LocalDateTime.now(CLOCK);
Jodastephen
source share