时间戳类的Vaadin表格列格式

时间戳类的Vaadin表格列格式,vaadin,Vaadin,我正在使用带有sql容器的表。容器的数据源是一个自由形式的查询。其中一个字段是发票日期,在sql server中,该字段是小日期时间。我已经重写了formatPropertyValue函数,在调试它时,property.getType正在返回时间戳。这就是我在函数中所做的 if (property.getType() == Timestamp.class) { SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");

我正在使用带有sql容器的表。容器的数据源是一个自由形式的查询。其中一个字段是发票日期,在sql server中,该字段是小日期时间。我已经重写了formatPropertyValue函数,在调试它时,property.getType正在返回时间戳。这就是我在函数中所做的

if (property.getType() == Timestamp.class) {
        SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
        if (property.getValue() == null) {
            return null;
        } else {
            System.out.println(df.format( (Date) property.getValue()));
            return df.format( (Date) property.getValue());

        }
    }
运行应用程序时,会出现com.vaadin.ui.table$cacheupdateexception错误

我改变了sql语句,比如query=selectconvertvarchar10,INVOICE\u DATE,110作为INVOICE\u DATE,。。。但我想知道是否有一种合适的方式来格式化时间戳字段

谢谢


托马斯·金

我发现我的代码有一个bug。应该是

return df.format( (Timestamp) property.getValue());
而不是

return df.format( (Date) property.getValue());

它现在正在工作。

当您看到在表组件中抛出com.vaadin.ui.table$cacheupdateexception错误,然后查看您收到的异常信息时,通常会出现导致实际问题的附加信息。空值、无效类等。我希望这种情况不会再次发生:但如果发生了,我会更仔细地看一看。谢谢你的信息!