当使用lazyquerycontainer和jpa加载数据时,vaadin日期格式无法正确格式化

时间:2015-08-04 09:51:49

标签: java jpa lazy-loading vaadin entitymanager

您好我正在使用与jpa集成的lazyquerycontainer。由于实体管理器加载数据,一些字段是bigdecimal格式,但我想以日期格式显示。在filtertable我也定义了一个装饰器,但它显示的格式是20,010,130。 这是我在桌子上可以做的事情吗? 请帮忙 谢谢。

1 个答案:

答案 0 :(得分:0)

如果我理解正确,可以覆盖表格以满足您的需要:

        Table t = new Table() {

        @Override
        protected String formatPropertyValue(Object rowId, Object colId,
                Property property) {
            Object v = property.getValue();
            if (v instanceof Date) {
                Date dateValue = (Date) v;
                return "Formatted date: " + (1900 + dateValue.getYear())
                        + "-" + dateValue.getMonth() + "-"
                        + dateValue.getDate();
            }
            return super.formatPropertyValue(rowId, colId, property);
        }

    };

来自vaadin forum

的示例
相关问题