admin管理员组文章数量:1326327
I'm using JSF Mojarra 2.3.17 and JRE 21. My bean has a LocalDate variable and the following JSF page:
<h:inputText value="#{bean.date1flt}" pt:type="date">
<f:convertDateTime type="localDate" pattern="yyyy-MM-dd" />
</h:inputText>
Why does it not have some sort of error message for "2024-06-31" when it's not a valid date (30 days in June). Instead, it sets the bean variable to null.
If I try LocalDate.of(2024, 6, 31);
I get java.time.DateTimeException: Invalid date 'JUNE 31'
, which is good, but nothing if I use JSF.
I'm using JSF Mojarra 2.3.17 and JRE 21. My bean has a LocalDate variable and the following JSF page:
<h:inputText value="#{bean.date1flt}" pt:type="date">
<f:convertDateTime type="localDate" pattern="yyyy-MM-dd" />
</h:inputText>
Why does it not have some sort of error message for "2024-06-31" when it's not a valid date (30 days in June). Instead, it sets the bean variable to null.
If I try LocalDate.of(2024, 6, 31);
I get java.time.DateTimeException: Invalid date 'JUNE 31'
, which is good, but nothing if I use JSF.
1 Answer
Reset to default 0It should indeed have used non-lenient parsing. This is also specifically requested in the spec:
In all cases, parsing must be non-lenient; the given string must strictly adhere to the parsing format.
This worked for java.util.Date
but not for its java.time.*
cousins. That's thus a bug in Mojarra. I fixed it for Mojarra 4.0.10.
In the meanwhile, your best bet is to use a custom converter.
本文标签: jsfHow to disallow invalid LocalDate in fconvertDateTimeStack Overflow
版权声明:本文标题:jsf - How to disallow invalid LocalDate in f:convertDateTime? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742202055a2432143.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论