Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-4731

TimeField not able to work with a java.sql.Time

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments


    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.5.8
    • Fix Version/s: 6.1.0, 1.5.9
    • Component/s: wicket-extensions
    • Labels:
    • Environment:
      Ubuntu 10.04, Wicket 1.5 Snapshot, Open JDK 1.6


      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.




            • Assignee:
              mgrigorov Martin Tzvetanov Grigorov
              shoe54 Shu


              • Created:

                Issue deployment