在jsp页面显示系统的当前日期及其时间,在xml文档中的格式不同其在页面上的格式化的格式将也要有所区别,否则将无法显示或者达不到想要的效果!!!以下举例说明:
在xml中定义格式: 格式1.<genDate><fmt:formatDate pattern="yyyy-MM-dd" value="${vipCardList.genDate}"/></genDate>
格式2.<genDate>${fn:substring(vipCardList.genDate,0,16)}</genDate>
而在js中显示时则要用对应的格式才能正确的读取日期,
即:格式1.{id:'genDate', xtype:"datefield", fieldLabel:"创建时间", name:"textvalue",readOnly:true ,format:'Y-m-d'}
格式2.{id:'genDate', xtype:"datefield", fieldLabel:"创建时间", name:"textvalue",format:'Y-m-d h:m',readOnly:true}
另外在添加数据时,日期的初始化形式应为(此为ajax编写的js页面代码):
格式1:{id:'genDate', xtype:"datefield", fieldLabel:"创建时间", name:"textvalue",format:'Y-m-d,readOnly:true, value:new Date() }或者{id:'genDate', xtype:"datefield", fieldLabel:"创建时间", name:"textvalue",readOnly:true }
格式2{id:'genDate', xtype:"datefield", fieldLabel:"创建时间", name:"textvalue",format:'Y-m-d h:m',readOnly:true, value:new Date() }
两者的区别是:格式1读取的日期精确到天,显示的时间格式为:YYYY-MM-DD;而格式2读取的日期精确到分,显示的时间格式为:YYYY-MM-DD HH:MM