Wicket
  1. Wicket
  2. WICKET-4731

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

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.5.8
    • Fix Version/s: 6.1.0, 1.5.9
    • Component/s: wicket-extensions
    • Labels:
      None
    • Environment:
      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.

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Martin Grigorov
            Reporter:
            Shu
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development