是否可以在表达式语言中创建日期值? [英] Is it possible to create a date value in Expression Language?

查看:104
本文介绍了是否可以在表达式语言中创建日期值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在不使用scriptlet的情况下在JSTL表达式语言(EL)中创建日期值?以下是我试图重构的仅使用EL的一些遗留代码的片段。

Is it possible to create a date value in JSTL Expression Language (EL) without using scriptlets? Here is a snippet of some of the legacy code I'm trying to refactor to only use EL.

<td><%=new java.text.SimpleDateFormat("MM/dd/yyyy HH:mm z").format(new java.util.Date())%></td>

显然它打印出当前的日期和时间。我知道我可以使用EL格式化日期,但是我可以使用EL获取日期吗?

Apparently it prints out the current date and time. I know I can format a date using EL, but can I get a date using EL?

推荐答案

我不认为你可以在EL中做到这一点。但是这个怎么样,这里没有scriptlet

I don't think you can do this in EL. But how about this, no scriptlets here

<jsp:useBean id="today" class="java.util.Date" scope="page" />
<fmt:formatDate value="${today}" pattern="MM.dd.yyyy" />

这篇关于是否可以在表达式语言中创建日期值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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