3
votes

I use vaadin 6.6 and joda DateTime 1.6.2 I use solution described at How to use DateField with Joda DateTime property?

Value is set/get correctly, but unfortunatelly I get Conversion exception:

Exception is throw inside BeanValidationValidator:

method is JodaDateTime and value is java.util.Date JodaTime is not assignable from Date JodaTime doesn't have String constructor

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);
        }
    }
}

Do you have some ideas???

2

2 Answers

0
votes

I haven't tried this myself, but from what I can see in BeanValidationValidator you'd need to extend this as well and add the implicit conversions between JodaTime and java.util.Date.

At least the BeanValidationValidator.validate(Object) method needs to handle this conversion.

0
votes

Take a look at PopupDateTimeField.java You can also use a PropertyConverter