0

次の形式で 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);
});

fieldListGrid の Date フィールドです。しかし、これは ListGrid に空白のフィールドを表示します。次の形式で表示する方法がわかりません。 22 Jul 2014 00:04

4

1 に答える 1

1

documentationによると、サーバーは次の形式で日付を送信する必要があります。

日付フィールド: "2007-04-22"

timeField: "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);
于 2015-01-05T19:48:34.163 に答える