Details
-
Improvement
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
1.5.8
-
None
-
Ubuntu 10.04, Wicket 1.5 Snapshot, Open JDK 1.6
Description
When using the TimeField with a model whose object is a java.sql.Time, I get an error similar to the following when submitting the form:
Last cause: Cannot parse '1/1/70' using format java.text.SimpleDateFormat@b4dc7db3
Here's how the TimeField is constructed:
TimeField tf = new TimeField(id, new Model<java.sql.Time>() {
public java.sql.Time getObject() {
// return java.sql.Time
}
});
This error is occurring because SqlTimeConverter is trying to convert the string representation of the java.util.Date obtained from the TimeField. TimeField doesn't support anything other than java.util.Date. It would be useful if TimeField could work with subclasses of java.util.Date such as java.sql.Time. In order to achieve this, I would like to propose:
Changing setConvertedInput(new Date(date.getMillis())); in DateTimeField.convertInput() to setConvertedInput(newDateInstance(date.getMillis()));
Create an overridable newDateInstance(long) method. Users of TimeField can override this method to create a java.sql.Time instance instead of a java.util.Date. The form component conversion process will then work when the model object is a java.sql.Time.