omGrid,返回頁面時間,一長串數字解決辦法

數據庫存儲時間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;
    };

 

發佈了19 篇原創文章 · 獲贊 2 · 訪問量 10萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章