omGrid,返回页面时间,一长串数字解决办法

来源:互联网 发布:数据库 文件系统 区别 编辑:程序博客网 时间:2024/06/05 00:12

数据库存储时间2012-9-4 9:57:10,正常

po对象

 @Temporal(TemporalType.TIMESTAMP)
 @Column(name = "LAST_UPDATE_DATE", nullable = false, length = 7)
 public Date getLastUpdateDate() {
  return this.lastUpdateDate;
 }

 

页面JS$('#grid').omGrid,部分代码

colModel : [ {header : '序号', name : 'uomClassId', width : 50, align : 'center',sort:'clientSide'},
                             {header : '物料单位分组名称', name : 'uomClass', width : 100, align : 'left',sort:'clientSide'}, 
                             {header : '创建时间', name : 'creationDate', width : 150, align : 'left',sort:'clientSide',
                                renderer : function(colValue, rowData, rowIndex) {
           if(colValue != ""){    
            colValue = getFormatDate(colValue,'yyyy-MM-dd hh:mm:ss');// getFormatDate依赖于tb-function.js
            }   
           return colValue;
          }//end renderer

        },
                             {header : '创建者', name : 'createdBy', width : 'autoExpand', align : 'left',sort:'clientSide'}
                           ]

 

 

页面JS里定义函数

//将返回页面的时间格式化
         function getFormatDate(date, dateformat)   {
     date = new Date(date);
     var format = dateformat||'yyyy-MM-dd hh:mm:ss';
     var o = {
      "M+" : date.getMonth() + 1,
      "d+" : date.getDate(),
      "h+" : date.getHours(),
      "m+" : date.getMinutes(),
      "s+" : date.getSeconds(),
      "q+" : Math.floor((date.getMonth() + 3) / 3),
      "S" : date.getMilliseconds()
     };
     if (/(y+)/.test(format)) {
      format = format.replace(RegExp.$1,
        (date.getFullYear() + "")
          .substr(4 - RegExp.$1.length));
     }
     for ( var k in o) {
      if (new RegExp("(" + k + ")").test(format)) {
       format = format
         .replace(
           RegExp.$1,
           RegExp.$1.length == 1 ? o[k]
             : ("00" + o[k])
               .substr(("" + o[k]).length));
      }
     }
     return format;
    };

 

原创粉丝点击