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
When using the new feature to set a global date pattern for all @RequestParam LocalDate arguments by specifying the property spring.mvc.date-format, which is discussed here, I noticed that the common ISO pattern yyyy-MM-dd does not work.
The exception thrown looks like this:
Failed to convert value of type 'java.lang.String' to required type 'java.time.LocalDate'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [@org.springframework.web.bind.annotation.RequestParam java.time.LocalDate] for value '2018-04-20'; nested exception is java.lang.IllegalArgumentException: Parse attempt failed for value [2018-04-20]
Through debugging, I found that the root cause is this exception:
Text '2018-04-20' could not be parsed: Unable to obtain LocalDate from TemporalAccessor: {DayOfMonth=20, YearOfEra=2018, MonthOfYear=4},ISO of type java.time.format.Parsed
And I also found that the DateTimeFormatter that gets used for parsing is represented like that by toString():
I presume that the reason why a LocalDate could not be obtained is that the TemporalAccessor that gets constructed lacks a value for the Era field, but has a filled YearOfEra field.
So I tried with uuuu-MM-dd instead, which works perfectly. @wilkinsona suspected that this is unintended and a symptom of a bug, therefore this bug report.
The text was updated successfully, but these errors were encountered:
When using the new feature to set a global date pattern for all
@RequestParam LocalDate
arguments by specifying the propertyspring.mvc.date-format
, which is discussed here, I noticed that the common ISO patternyyyy-MM-dd
does not work.The exception thrown looks like this:
Through debugging, I found that the root cause is this exception:
And I also found that the DateTimeFormatter that gets used for parsing is represented like that by
toString()
:I presume that the reason why a
LocalDate
could not be obtained is that theTemporalAccessor
that gets constructed lacks a value for theEra
field, but has a filledYearOfEra
field.So I tried with
uuuu-MM-dd
instead, which works perfectly. @wilkinsona suspected that this is unintended and a symptom of a bug, therefore this bug report.The text was updated successfully, but these errors were encountered: