It may be worth adding to the documentation (chapter 2.8.8) that ChronoUnit.WEEKS is not supported in @PeriodUnit annotation to specify how to interpret unqualified integer values for Period configuration properties fields.

Specifying weeks fails with a root cause of:

...
Caused by: java.lang.IllegalArgumentException: '2' is not a valid simple period
    at org.springframework.boot.convert.PeriodStyle$1.parse(PeriodStyle.java:59) ~[spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
    at org.springframework.boot.convert.StringToPeriodConverter.convert(StringToPeriodConverter.java:65) ~[spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
    at org.springframework.boot.convert.StringToPeriodConverter.convert(StringToPeriodConverter.java:50) ~[spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
    at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:41) ~[spring-core-5.2.7.RELEASE.jar:5.2.7.RELEASE]
    ... 57 common frames omitted
Caused by: java.lang.IllegalArgumentException: Unsupported unit Weeks
    at org.springframework.boot.convert.PeriodStyle$Unit.fromChronoUnit(PeriodStyle.java:273) ~[spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
    at org.springframework.boot.convert.PeriodStyle$1.parse(PeriodStyle.java:47) ~[spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
    ... 60 common frames omitted

Comment From: wilkinsona

Thanks, @AlexFalappa. This looks like a bug to me. We support weeks with the ISO-8601 and simple formats. Unless I've missed something, there's no reason why they're not also supported when specify an int and a ChronoUnit of weeks.

Period has no accessor for weeks but I don't believe we need one. For String -> Period conversion we don't access any of the components of the period. For Period -> String conversion we only need years, months, and days. I think we can safely add WEEKS to PeriodStyle.Unit that supports parsing but not printing.