java中,根据后台传递的Date类型的数据,前台如何接受问题

//修改日期格式
	function getLocalTime(jsondate) { 
		jsondate=""+jsondate+"";//因为jsonDate是number型的indexOf会报错
		if (jsondate.indexOf("+") > 0) {
		      jsondate = jsondate.substring(0, jsondate.indexOf("+"));
		    }
		    else if (jsondate.indexOf("-") > 0) {
		         jsondate = jsondate.substring(0, jsondate.indexOf("-"));
		    }
		    var date = new Date(parseInt(jsondate, 10));
		    var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
		    var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
		    var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
		    var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
		    var seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
		    return date.getFullYear() + "-" + month + "-" + currentDate + " " + hours + ":" + minutes + ":" + seconds;
		}  

直接将日期传递进来会自动编译

猜你喜欢

转载自blog.csdn.net/weixin_42932323/article/details/84172749