Search code examples
grailstimegroovygsp

How to use g:datePicker in grails gsp to pick a time?


By using g:datePicker on java.sql.Time object that refers to a TIME legacy DB column I get this error:

Failed to convert property value of type java.util.GregorianCalendar to required type java.sql.Time for property jobTime; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [java.util.GregorianCalendar] to required type [java.sql.Time] for property jobTime: PropertyEditor [org.codehaus.groovy.grails.web.binding.StructuredDateEditor] returned inappropriate value

I've searched through the whole web for hours but can't still figure out how to do, is there someone who can help please?


Solution

  • It looks like you're trying to convert a GregorianCalendar object to a Time object (at least, that's what the object says its doing). Try manually doing it:

    // assuming that 'jobTime' is the object you're dealing with
    jobTime = new java.sql.Time(jobTime.getTimeInMillis())
    

    If you're absolutely sure its a Time object, try converting it to a Date object.

    jobTime = new Date(jobTime.getTime())