Search code examples
grailsjodatimegsp

Send LocalTime object via parameters from gsp in Grails


I've input time field in my Grails application:

<joda:timePicker name="startTimeReservation" value="${new LocalTime()}" precision="minute" />

I want to send its value to action in controller via parameters. This is a code from controller where I catch this value:

oldCafeeInfo.startTimeLimit = params['startTimeReservation']

During parameters are send, I get a such error:

Cannot cast object 'struct' with class 'java.lang.String' to class 'org.joda.time.LocalTime'

How to send parameters correctly?


Solution

  • I found my own alternative. I noticed what params['startTimeReservation'] comes to controller as a string "struct". Also, in logs, I noticed, what this struct is divide by startTimeReservation_hour and startTimeReservation_minutes. They contain integer-values, which are parse easy! Then these values may be transfered as parameters to the new LocalTime(hour, minute). So we've created new LocalTime instance which can be recorded to the database. Somehow, I doubt this is a good variant, but it works.