Lines 1 Date Format

Is there any tag in the Struts1 tag library that can format an object java.util.Date?

In Struts 2, I can use the tag s:date, but I cannot find the equivalent of Struts 1.

+5
source share
3 answers

Nothing of the kind in the link to Sruts tags . However, you can use the JSTL tag fmt:formatDatefor this. JSTL and Struts1 almost go hand in hand.

<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
...
<p><fmt:formatDate value="${bean.date}" pattern="yyyy-MM-dd" />
<p><fmt:formatDate value="${bean.date}" type="date" dateStyle="long" />

Which should print as:

2010-06-18
June 18, 2010

He uses java.text.SimpleDateFormatunder the hoods. His Javadoc describes in more detail the available templates and styles.

+5
source

? - :

bean:write name=xxxx  format="MMMM-dd-yyyy"
+6

format="MM-dd-yyyy" bean:write.

+3
source

All Articles