JSTL LocalDateTime格式 [英] JSTL LocalDateTime format

查看:564
本文介绍了JSTL LocalDateTime格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以"dd.MM.yyyy "模式设置Java 8 LocalDateTime对象的格式.有没有要格式化的库?我在下面尝试了代码,但遇到了转换异常.

I want to format my Java 8 LocalDateTime object in "dd.MM.yyyy" pattern. Is there any library to format? I tried code below but got conversion exception.

<fmt:parseDate value="${date}" pattern="yyyy-MM-dd" var="parsedDate" type="date" />

JSTL中的LocalDateTime类是否有任何标签或转换器?

Is there any tag or converter for LocalDateTime class in JSTL?

推荐答案

实际上,我遇到了同样的问题,最终分叉了原始的Joda Time jsp标签来创建

Actually I had the same problem and ended up forking the original Joda Time jsp tags to create Java 8 java.time JSP tags.

有了该库,您的示例将如下所示:

With that library your example would be something like this:

<javatime:parseLocalDateTime value="${date}" pattern="yyyy-MM-dd" var="parsedDate" />

检查存储库中的安装说明: https://github.com/sargue/java-time -jsptags

Check the repository for installation instructions: https://github.com/sargue/java-time-jsptags

这篇关于JSTL LocalDateTime格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆