I'm using Instant.now()
to get the current UTC millis, and then truncate it to the nearest hour. All my JUnit
are failing because they are taking the current System time. How can I make Instant.now()
return a fixed value which I could supply in the JUnit
test.
public static Long getCurrentHour() {
Instant now = Instant.now();
Instant cH = now.truncatedTo(ChronoUnit.HOURS);
return cH.toEpochMilli();
}