Why is adding weeks to java.time.Instant not supported?

It throws UnsupportedTemporalTypeException 7 days week is not universal and constant. It may vary of different calendar system. For example, look on the Akan calendar system which uses 6 days a week.


The Instant class deals with absolute time, and tries to avoid all ambiguities related to how different calendar systems, regions and cultures group and interpret it.

Some calendar systems have different week lengths, some have different month groupings, have years that start on a different date, and adjust for leap years and leap seconds in different ways (if at all, like in the case of the Julian calendar which had too many leap years and drifted from the 'physical' phenomena they were supposed to be in sync with, like the seasons, solstices and equinox).

To avoid these problems the Instant class allows you to use the more precisely defined and standardised units like the seconds, minutes, hours and days.

Leap seconds are 'smoothened' out in Java, over the last 1000 seconds of the day on which they occur, so from a programmer's perspective they do not exist. (Computer clocks are not that accurate anyway, and need to sync frequently with NTP.)

1 day is assumed to be 24 SI hours, with 1 SI hour defined as 60 SI minutes, 1 SI minute defined as 60 SI seconds, and 1 SI second being 9,192,631,770 radiation periods of Caesium-133. 24hrs is actually the mean Solar Day (time elapsed between two successive 'noons'), because due to elliptical orbits, the orbit of the sun itself, and variations in orbit speed, each solar day could be slightly longer or shorter.

One important thing you have to be careful of is Daylight Saving. In those special days, a day is 25 hours or 23 hours, depending on which direction the clock moves. However, the Instant class doesn't care about this, it will still move 24 hours if you add 1 day over the daylight savings boundary. It doesn't carry any timezone or regional information (DST is country specific).