jsp页面将Date类型的日期的"yyyy-MM-dd HH:mm:ss"格式化显示

示例如下:

<table id="contentTable" class="table table-striped table-bordered table-condensed">
        <thead><tr><th>订单编号</th><th>商品名称</th><th>客户名称</th><th>商品成交数量</th><th>商品单价</th><th>成交总额</th><th>交易时间</th><th>订单状态</th><shiro:hasPermission name="sys:order:edit"><th>操作</th></shiro:hasPermission></tr></thead>
        <tbody>
                    <c:forEach items="${page.list}" var="order">
                    <tr>
                    
                <td>${order.orderId}</td>
                <td>${order.goodId}</td>
                <td>${order.shopperName}</td>
                <td>${order.goodNumber}</td>
                <td>${order.goodPrice}</td>
                <td>${order.sumPrice}</td>
                <%-- <td>${order.saleTime}</td> --%>
                <td><fmt:formatDate value="${order.saleTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                <td>${order.orderStatus=="1"?"待审核":(order.orderStatus=="0"?"未通过":"已通过")}</td><!-- 1 代表待审核   0代表未通过  2 代表已通过 -->
            
            <shiro:hasAnyPermissions name="sys:order:edit">
                <td>
                    <a href="${ctx}/sys/order/form?orderId=${order.orderId}">修改</a>
                    <a href="${ctx}/sys/order/delete?orderId=${order.orderId}">删除</a>
                
                </td>
            </shiro:hasAnyPermissions>
            </tr>
            </c:forEach>
        
        </tbody>
    
    </table>

头部加上:     <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
内容中使用:   <fmt:formatDate value="${post.postDate }" pattern="yyyy-MM-dd HH:mm:ss"/>   显示时分秒

                      或者 <fmt:formatDate value="${post.postDate }" pattern="yyyy-MM-dd"/>     显示时分秒显示

将时间转换成自己想要的格式      

猜你喜欢

转载自www.cnblogs.com/isme-zjh/p/12664101.html