2011-05-26 160 views
3

我用vaadin 6.6和乔达日期时间1.6.2 我用在How to use DateField with Joda DateTime property?Vaadin与乔达日期时间

值描述的方案是设置/获取正确的,但可惜的是我得到的转换异常:

例外是里面扔BeanValidationValidator:

方法是JodaDateTime和价值是java.util.Date JodaTime是不是从日期 分配JodaTime没有String构造

 
private Object convertValue(Object value) 
     throws Property.ConversionException { 
    // Try to assign the compatible value directly 
    if (value == null 
      || method.getType().isAssignableFrom(value.getClass())) { 
     return value; 
    } else { 
     try { 
      // Gets the string constructor 
      final Constructor constr = method.getType().getConstructor(
        new Class[] { String.class }); 

      return constr.newInstance(new Object[] { value.toString() }); 

     } catch (final java.lang.Exception e) { 
      throw new Property.ConversionException(e); 
     } 
    } 
}

你有什么想法?

回答

0

我还没有尝试过这个,但是从我在BeanValidationValidator中可以看到的内容中,您还需要对此进行扩展,并在JodaTime和java.util.Date之间添加隐式转换。

至少BeanValidationValidator.validate(Object)方法需要处理此转换。