Ext表格中关于显示时间的问题

悬赏:10 发布时间:2008-07-24 提问人:appleboy (初级程序员)

最近在学习Ext的表格,遇到一个很头疼的问题,希望大家给予帮助。

问题是这样的,后台使用J2EE,日期使用java.util.Date类型,我用JSON-LIB将其格式化后获得类似于这样的数据:
"intoDate":{"date":23,"day":3,"hours":0,"minutes":0,"month":6,"nanos":0,"seconds":0,"time":1216742400000,"timezoneOffset":-480,"year":108}


前台Ext相关代码:
{
        header: '进货日期',
        dataIndex: 'intoDate',
        sortable: true,
        width: 150,
        renderer:parseDate
    }


function parseDate(value,p,record){
		var dateTime = record.data.intoDate;
                  //return dateTime["year"];//这种方法无法获取数据
		return dateTime.year;//这样也不行
	}


大家有什么办法吗?
该问题已经关闭: 超过15天由系统自动关闭,悬赏平分给所有参与回答的会员

回答

这个你只要convert一下就可以用
var dateime=new Date(record.data.intoDate);
行了。
Date支持这种长整形的。
jljlpch (初级程序员) 2008-07-24
function parseDate(value){
var dateTime = new Date(Integer.parse(value.get('time')));
return dateTime.format('Y-m-d');
}
kimmking (中级程序员) 2008-08-04
用Ext里的Date类,API如下:
Date.parseDate( String input, String format ) : Date
<static> Parses the passed string using the specified format. Note that this function expects dates in normal c...
<static> Parses the passed string using the specified format. Note that this function expects dates in normal calendar format, meaning that months are 1-based (1 = January) and not zero-based like in JavaScript dates. Any part of the date format that is not specified will default to the current date value for that part. Time parts can also be specified, but default to 0. Keep in mind that the input date string must precisely match the specified format string or the parse operation will fail. Example Usage:
//dt = Fri May 25 2007 (current date)
var dt = new Date();

//dt = Thu May 25 2006 (today's month/day in 2006)
dt = Date.parseDate("2006", "Y");

//dt = Sun Jan 15 2006 (all date parts specified)
dt = Date.parseDate("2006-01-15", "Y-m-d");

//dt = Sun Jan 15 2006 15:20:01 GMT-0600 (CST)
dt = Date.parseDate("2006-01-15 3:20:01 PM", "Y-m-d h:i:s A" );
Parameters:

input : String
The unparsed date as a string.
format : String
The format the date is in.
Returns:

Date
The parsed date.
chanball (初级程序员) 2008-08-05