Instantshould not be passed unsupported temporal unit types JAVA-E1094
java.time.Instant methods like
until() should not be passed invalid temporal units in their second argument, as this could cause a crash.
Only pass one of
DAYS as the second argument to these methods.
These three methods of
Instant only accept time units at a maximum scale of
ChronoUnit.DAYS, meaning that any units other than that will be rejected with an exception.
Instant instant = Instant.now(); instant.plus(1, ChronoUnit.WEEKS); // You can't add weeks to an instant!
This code would trigger an
UnsupportedTemporalTypeException at runtime.
ChronoUnit.DAYS and below to perform operations on
Instant instant = Instant.now(); instant.plus(1, ChronoUnit.HALF_DAYS);