js页面
/**
* 得到特定格式的日期形式
* @param {Object} d
*/
function getCurrentDate(dd) {
if (dd == null || dd.length == 0) {
return "";
}
if (dd.length == 10) {
return dd;
}
var d = new Date(dd);
var month = d.getMonth() + 1;
var day = d.getDate();
var str = d.getFullYear() + "-";
if (month < 10) {
str += ("0" + month)
} else {
str += month;
}
str += "-";
if (day < 10) {
str += ("0" + day)
} else {
str += day
}
return str;
}
var accepttime = records[i].data["accepttime"] == null?"":getCurrentDate(records[i].data["accepttime"]);
// alert(records[i].data["accepttime"]);
从日历接收的日期为
// alert(accepttime);
经过getCurrentDate 转换之后
后台
if(riskClass.getAccepttime1()!=null&&!"".equals(riskClass.getAccepttime1()))
{
System.out.println(riskClass.getAccepttime1());
riskClass.setLimitdate(BaseUtil.getCST(riskClass.getAccepttime1()));
System.out.println(BaseUtil.getCST(riskClass.getAccepttime1()));
}
public static Date getCST(String uct) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat(
"EEE MMM dd HH:mm:ss 'UTC+0800' yyyy", Locale.ENGLISH);
Date date;
if (uct.length() <= 10) {
sdf = new SimpleDateFormat("yyyy-MM-dd");
}
date = sdf.parse(uct);
return date;
}
2017-08-23// System.out.println(riskClass.getAccepttime1());
Wed Aug 23 00:00:00 CST 2017// System.out.println(BaseUtil.getCST(riskClass.getAccepttime1()));
从后台获取前台显示
id: 'endtimeid',
header: '计划完成时间',
dataIndex: 'acceptendtime1',
width: 150,
editor : new Ext.form.DateField({
format:"Y-m-d"
}),
renderer : function(value) {
if (value instanceof Date) {
return new Date(value).format('Y-m-d');
} else {
return value;
}
}