How to format date in JSTL

前端 未结 1 1783
渐次进展
渐次进展 2020-12-06 17:36

I have a loop that goes through all the news items we have on our site. One of the fields is date ${newsitem.value[\'Date\']}, given in millliseconds. I\'d like

1条回答
  •  误落风尘
    2020-12-06 18:04

    Yes the JSTL formatDate tag should do the job in combination with changing the Timestamp value into a date object (which is required to work around the exception mentioned in your comment).

    Ensure that you have properly defined the fmt prefix in the JSP declarations

    <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
    

    Render the output, convert the time stamp to a date value first. I'm using yyyy-MM-dd as the format pattern, the dateFormat tag supports other formatting options as well.

    
    
    
    

    0 讨论(0)
提交回复
热议问题