java jsp頁面上顯示的時間為一串數字和jsp頁面時分秒顯示為0


 

 

 

 網上有的說是需要在實體上加注解 

我這里在jsp頁面解決的   

 

 

 

 

代碼如下 :

function timestampToTime(timestamp) {
if(timestamp == '' || timestamp == null || typeof(timestamp) == "undefined"){
return "";
}
var date = new Date(timestamp);//時間戳為10位需*1000,時間戳為13位的話不需乘1000

var date = new Date(timestamp*1000);
Y = date.getFullYear() + '-';
M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
D = date.getDate() + ' ';
h = date.getHours() + ':';
m = date.getMinutes() + ':';
s = date.getSeconds();
return Y+M+D+h+m+s;
}

 

去掉頁面顯示時間時  時 分 秒  為0   2020-03-03 00:00:00

<tr height="30px;" >
  <td class="td_head" nowrap width="30%">組織機構代碼有效期</td>
  <td class="td_body" nowrap id="insTerm">
    ${strPolicy.strInsured.insTerm}
  </td>
</tr>

 

//將日期后邊的0去掉
var insTerm = $("#insTerm").html();
insTerm = insTerm.replace("00:00:00.0","");
$("#insTerm").html(insTerm);

 

也可以

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

<fmt:formatDate value="${xxxxx.plcyBndTime}" pattern="yyyy-MM-dd HH:mm:ss" />

<fmt:formatDate value="${xxxxx.plcyBndTime}" pattern="yyyy-MM-dd " />


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM