JSTL formatDate和java.time.LocalDate [英] JSTL formatDate and java.time.LocalDate
本文介绍了JSTL formatDate和java.time.LocalDate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法弄清楚如何在JSP中显示 java.time.LocalDate
值。在我的JSP中,我有这个:
I haven't been able to figure out how to display a java.time.LocalDate
value in a JSP. In my JSP, I have this:
<fmt:formatDate value="${std.datum}" type="date" pattern="dd.MM.yyyy" var="stdDatum" />
std.datum的类型为java.time.LocalDate。渲染jsp时我得到这个异常:
std.datum is of type java.time.LocalDate. When rendering the jsp I get this exception:
javax.el.ELException: Cannot convert 2015-02-14 of type class java.time.LocalDate to class java.util.Date
我假设它是转换?
谢谢,
约翰。
Thanks, john.
推荐答案
是的。您可以使用fmt:parseDate进行转换,然后进行格式化。
以下示例
Yes. You could use fmt:parseDate to do the conversion and then do the formatting. Example below
<fmt:parseDate value="${std.datum}" pattern="yyyy-MM-dd"
var="parsedDate" type="date" />
<fmt:formatDate value="${parsedDate}" var="stdDatum"
type="date" pattern="dd.MM.yyyy" />
祝你好运。
这篇关于JSTL formatDate和java.time.LocalDate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文