Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Date 在Smartgwt项目中以正确格式显示日期_Date_Smartgwt_Listgrid - Fatal编程技术网

Date 在Smartgwt项目中以正确格式显示日期

Date 在Smartgwt项目中以正确格式显示日期,date,smartgwt,listgrid,Date,Smartgwt,Listgrid,我从JSON获得的日期格式如下22 07 2014 12:04:12。 这是我写的代码: field.setCellFormatter(new CellFormatter() { @Override public String format(Object arg0, ListGridRecord arg1, int arg2, int arg3) { final DateTimeFormat fmt = DateTimeFormat.getFormat("dd M

我从JSON获得的日期格式如下
22 07 2014 12:04:12
。 这是我写的代码:

field.setCellFormatter(new CellFormatter() {
    @Override
    public String format(Object arg0, ListGridRecord arg1, int arg2, int arg3) {
        final DateTimeFormat fmt = DateTimeFormat.getFormat("dd MM yyyy hh:mm");
        final Date date = (Date) arg0;

            arg1.setAttribute(name, date);
            return fmt.format(date);
});
其中,
字段
是ListGrid中的日期字段。 但这会在ListGrid中显示一个空白字段。我想不出用以下格式显示它的方法:
2014年7月22日00:04

根据,服务器必须以以下格式发送日期:

日期栏:“2007-04-22”

时间域:“11:07:13”

dateTimeField:“2007-04-22T11:07:13”

dateTimeField:“2007-04-22T11:07:13.582”

您可以通过以下代码段实现这一点:

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
sdf.format(myDate);
然后,在客户端,您可以使用SmartGWT格式化日期:

myListGridField.setDateFormatter(DateDisplayFormat.TOEUROPEANSHORTDATETIME);