The following piece of code:
Instant inFourWeeks = Instant.now().plus(4L, ChronoUnit.WEEKS);
Throws an exception:
java.time
Other Answers are correct. I am adding this bit of clarification.
Instant is basic building-blockThe Instant class is a basic building-block in the java.time classes. It represent a moment, a point on the timeline. Internally it is simply a count of whole seconds since the epoch reference of first moment of 1970 in UTC. So this class is deserving of little functionality.
This building-block may be used to track a moment in any of many possible calendaring systems. Making sense of an Instant, to treat it as a date, week, month, and so on is up to the definitions of a particular calendaring system. A calendaring system can define any number of days in a week, or any number of months in a year, and so on, or may not even have such concepts as week or month.
The most obvious calendar system is the modern ISO 8601 used throughout the West and other parts of the world. The OffsetDateTime & ZonedDateTime classes built on top of Instant to make up key parts of this ISO calendaring system. These classes are bundled with Instant merely because they are expected to be commonly used by many Java programmers. But they are by no means the only calendaring system.
Look to the java.time.chrono package for these various calendar systems:
HijrahChronologyIsoChronology JapaneseChronologyMinguoChronologyThaiBuddhistChronologyThe ThreeTen-Extra project provides additional functionality to the java.time classes. This includes more calendaring systems:
AccountingChronologyBritishCutoverChronologyCopticChronologyDiscordianChronologyInternationalFixedChronologyJulianChronologyPaxChronologySymmetry010ChronologySymmetry454ChronologyThere may be yet more from third-parties that I am not aware of.