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

ClassCastException in SqlDateConverter

    XMLWordPrintableJSON

Details

    Description

      When converting a date string to a java.sql.Date you'll always get a ClassCastException like this one:

      java.lang.ClassCastException: java.util.Date cannot be cast to java.sql.Date
      at org.apache.wicket.util.convert.converters.SqlDateConverter.convertToObject(SqlDateConverter.java:43)

      Reason is DateFormat.parse() returns a java.util.Date, which is cast to java.sql.Date. One solution would be

      return new Date(((java.util.Date)parse(getDateFormat(locale), value, locale)).getTime())

      See https://issues.apache.org/jira/browse/WICKET-2309

      The problem had been fixed in version 1.4, but the (java.util.Date) code was remove on 1.5 but It's very important to don't have this error.

      Attachments

        Activity

          People

            mgrigorov Martin Tzvetanov Grigorov
            dutrieux Duto
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: