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

前端 未结 5 1919
醉话见心
醉话见心 2021-01-18 05:50

The following piece of code:

Instant inFourWeeks = Instant.now().plus(4L, ChronoUnit.WEEKS);

Throws an exception:

java.time         


        
5条回答
  •  生来不讨喜
    2021-01-18 06:07

    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.

提交回复
热议问题