You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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.
wilkinsona
changed the title
Document supported ChronoUnit values for @PeriodUnit annotation
Period conversion does not support a ChronoUnit of WEEKS but supports weeks in ISO-8601 (e.g. P2W) and simple (e.g. 2w) formats
Jul 6, 2020
wilkinsona
changed the title
Period conversion does not support a ChronoUnit of WEEKS but supports weeks in ISO-8601 (e.g. P2W) and simple (e.g. 2w) formats
Period conversion does not support a ChronoUnit of WEEKS but supports weeks in ISO-8601 (e.g. P2W) and simple (e.g. 2w) formats
Jul 6, 2020
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 forPeriod
configuration properties fields.Specifying weeks fails with a root cause of:
The text was updated successfully, but these errors were encountered: