I have this code
Instant now = Instant.now();
if (amountDays >= 0) {
now = now.plus(amountDays, ChronoUnit.DAYS);
} else {
now = now.minus(Math.abs(amountDays), ChronoUnit.DAYS);
}
And I was thinking to simplify it like this
Instant now = Instant.now();
now = now.plus(amountDays, ChronoUnit.DAYS);
However, I am unsure if plus works correctly with negative values or if that messes up the result.
Can I use plus like that, with possibly negative values?