开发者

Using JSTL's formatDate function with a date represented in milliseconds

开发者 https://www.devze.com 2023-04-05 17:39 出处:网络
Normally I use the following to display a Date object in a JSP page: <fmt:formatDate value=\"${blogEntry.created}\"/>

Normally I use the following to display a Date object in a JSP page:

<fmt:formatDate value="${blogEntry.created}"/>

Works great if blogEn开发者_Go百科try.created is a java.util.Date object. But what's the proper way to display a date if you only have a date in milliseconds? Do I have to first set a variable with escaped Java code like <%=new java.util.Date(millis);%>? Or is there a better way?


Can you just add a method to the BlogEntry class that returns the date as a proper java.util.Date?

<fmt:formatDate value="${blogEntry.createdAsDate}"/>
0

精彩评论

暂无评论...
验证码 换一张
取 消