I. El expressions
First, introduce <FMT> tags, <% @ taglib prefix = "FMT" uri = "http://java.sun.com/jsp/jstl/fmt" %> On the JSP page.
Second, use the El expression as the value of the FMT tag attribute. Add the pattern parameter to specify the format to be formatted for the date, for example, yyyy-mm-dd. For example:
<FMT: formatdate value = "$ {object. dateproperty}" pattern = "yyyy-mm-dd hh: mm"/>
Ii. Struts tag Library
First, import the struts tag library on the JSP page :. Similar to the El expression, we need to specify the format as the parameter for formatting the date in the S: Date tag, and specify the date attribute to be formatted as the value of the name attribute, for example:
<S: Date name = "# object. dateproperty" format = "yyyy-mm-dd hh: mm"/>
Note: # object. dateproperty is written in name, but object. dateproperty cannot be written. # must be added #.
Appendix: unformatted display:
Formatted and displayed:
Format the date object in the El expression or struts tag library to convert date to yyyy-mm-dd format.