• 【JavaScript】JAVA-js中比较日期大小


    业务场景:js中根据yyyy-MM-dd格式的日期进行比较来动态显示相关图标的出现与否

    var DS173305 = {
        DS173305Grid: null,
        initDataGrid: function () {
            DS173305.DS173305Grid = $('#DS173305_Grid').grid({
                actionHandler:DS173305.actionHandler,
                fnRowCallback:DS173305.rowCallback
            });
        },
        actionHandler:function(rowdata,coltype,row,col){
            if(coltype=="edit"){
                    $.pdialog.open("供应商产品实际录入", Main.contextPath + "/DS173304/init", {
                             800,
                            height: 550
                        },
                        {
                            entryMark : "2",
                            distMonth : rowdata.distMonth,
                            areaCode : rowdata.lgcsCode,
                            areaName : rowdata.lgcsName,
                            supplierCode : rowdata.suppCode,
                            supplierName : "临时数据",
    
                            productName : rowdata.classesName,
                            currentHalfCode : rowdata.halfCodeZ,
                            planType : rowdata.pdStockType,
                            adjustDate : rowdata.inputDate,
                        })
            };
            if(coltype=="delete"){
                $('#main-content').postUrl(Main.contextPath + "/DS173305/delete/", {
                    suppDsId : rowdata.suppDsId,
                    actualFlowId : rowdata.actualFlowId,
                })};
        },
        rowCallback: function (tr, data) {
            var $td = $(tr).children('td').eq(18);
            var theB=$td[0].children[1];
            var theA=$td[0].children[0];
    
            var d = new Date();
            var str = d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
            var dstr = new Date(str.replace(/-/g, "/"));
    
            var a = data.halfCodeA;
            var astr = new Date(a.replace(/-/g, "/"));
    
            var i = data.inputDate.toString();
            var istr = new Date(i.replace(/-/g, "/"));
            if(istr-astr<0 || dstr-istr<0){
                theA.style.visibility="hidden";
                theB.style.visibility="hidden";
            }
        }
    }
    $(document).ready(function () {
        // 初始化调用
        DS173305.initDataGrid();
    });

    java代码里将date转化为指定格式为:

    Date d = new Date();
    SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String date = sdf.format(d);
  • 相关阅读:
    android基本架构
    c#编辑框只接受数字
    listbox数据源绑定问题
    QQ在线客服代码
    用VB生成DLL封装ASP代码例子
    C#,关于DataGridView的一些方法
    转:ASP.NET中引用dll“找不到指定模块"的完美解决办法
    编译asp.net文件为dll文件
    好看的表格样式
    网站IIS日志解读
  • 原文地址:https://www.cnblogs.com/dflmg/p/5212863.html
Copyright © 2020-2023  润新知