時間的存儲與顯示

oracle數據庫中crtdate存儲類型爲date類型:clipboard.png
存儲形式:
clipboard.pngjavascript

model類中存儲類型爲date類型,注意導包是util包下的:clipboard.pnghtml

java後臺:

@RequestMapping("/prepdt")java

public String prepdt(
        @RequestParam(value = "pageNumber", required = false, defaultValue = "1")int pageNumber,
        @RequestParam(value = "pageSize", required = false, defaultValue = "10")int pageSize,
        @RequestParam(value = "pdtname", required = false, defaultValue = "") String  pdtname,
        @RequestParam(value = "pdtcode", required = false, defaultValue = "") String  pdtcode,
        @RequestParam(value = "pdtitem", required = false, defaultValue = "") String  pdtitem,
        @RequestParam(value = "startDate", required = false, defaultValue = "") String  startDate,
        @RequestParam(value = "endDate", required = false, defaultValue = "") String  endDate,
        Model model,HttpSession session) throws Exception{
    pdtname=pdtname.trim();
    pdtcode=pdtcode.trim();
    List<Product> pdtList =productService.queryAllProductionByPage(pageNumber,pageSize,pdtname,pdtcode,startDate,endDate,pdtitem);
    System.out.println(pdtList.get(0).getCrtdate());
    int allcount=productService.queryAllProductionNum(pdtname, pdtcode, startDate, endDate,pdtitem);
    model.addAttribute("allcount", allcount);
    model.addAttribute("list", pdtList);
    model.addAttribute("pageNumber", pageNumber);
    model.addAttribute("pageSize", pageSize);
    model.addAttribute("pdtname", pdtname);
    model.addAttribute("pdtcode", pdtcode);
    model.addAttribute("pdtitem", pdtitem);
    model.addAttribute("startDate", startDate);
    model.addAttribute("endDate", endDate);
    return "product/pdtlist2";
}

控制檯打印出來的crtdate的值:Mon Sep 25 18:47:32 CST 2017數據庫

前臺顯示:

<c:forEach items="${list }" var="l">session

<tr style="border: ">
            <td  bgcolor="#FFFFFF" class="headtd"> ${l.pdtcode }</td>
            <td  bgcolor="#FFFFFF" class="headtd"> ${l.pdtitem }</td>
            <td  bgcolor="#FFFFFF" class="headtd"> ${l.pdtname }</td>
            <td  bgcolor="#FFFFFF" class="headtd"> <fmt:formatDate value="${l.crtdate}" type="both" /></td>
            <td  bgcolor="#FFFFFF" style="padding-top: 15px;padding-bottom: 15px;" class="headtd">
             ${l.crtrealname }
             </td>
            <td  bgcolor="#FFFFFF" class="headtd">
            <a href="javascript:void(0)" onclick="update('${l.id}')"><img src="<%=basePath%>static/img/edit.png">修改</a>
            <a href="javascript:void(0)" onclick="remove('${l.id}')"><img src="<%=basePath%>static/img/edit.png">刪除</a>
            </td>
            </tr>
        </c:forEach>

使用jstl的標籤:<fmt:formatDate value="${l.crtdate}" type="both" />
顯示:
clipboard.pngoracle

關於fmt:formatDate標籤的使用:http://www.runoob.com/jsp/jst...app

相關文章
相關標籤/搜索