extjs日期的转换

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;
                    }
                }
           



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值