I am new to java 8 and I am trying to get five years before now, here is my code:
Instant fiveYearsBefore = Instant.now().plus(-5, ChronoUnit.YEARS);
But I get the following error:
java.time.temporal.UnsupportedTemporalTypeException: Unsupported unit: Years
Can anyone help me how to do that?
1968: 50 years ago | Smithsonian Institution.
This year is 365 days, 6 hours, 9 minutes and 9 seconds, or about 365.26 days long.
90 days from now Today is August 27, 2022 so that means that 90 days from today would be November 25, 2022.
ZonedDateTime.now().minusYears(5).toInstant()
That will use your default time zone to compute the time. If you want another one, specify it in now()
. For example:
ZonedDateTime.now(ZoneOffset.UTC).minusYears(5).toInstant()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With