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>
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?
An expression language is a language for creating a computer-interpretable representation of specific knowledge and may refer to: Advanced Boolean Expression Language, an obsolete hardware description language for hardware descriptions.
An expression language makes it possible to easily access application data stored in JavaBeans components. For example, the JSP expression language allows a page author to access a bean using simple syntax such as ${name} for a simple variable or ${name.
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" />
Thid would be helpfull if you use spring webflow framework
if you define this on the flow.xml
<on-start>
<set name="flowScope.now" value="new java.util.Date()" />
</on-start>
You can get the value like this
<fmt:formatDate value="#{now}" pattern="MM.dd.yyyy" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With