0

I make a simple domain class

class Meetings {

    Date when
    String where
}

Then I run 'generate-all' on Meetings. I then start the app 'RunApp'. In the app I'm able to to choose the month, day, and year for the when variable, however I can't choose the time as in hours:minutes (example 7:30). I wouldn't expect to be able to do this, but if I save the date it formats it as month, day, year, and then -00:00:00. How do I set the time using the date variable? or is there another way?

Burt Beckwith
  • 75,342
  • 5
  • 143
  • 156

1 Answers1

0

If you are using the datepicker tag in grails, it is pretty straight forward. In the views folder under a domain class folder there is _form.gsp. Inside _form.gsp is a date picker tag.

<g:datePicker name="dateTimeVariableName" value="${dateTimeValue}"
          default="${new Date().clearTime()}" precision="minute"/>

The keyword here is precision.

You should check the documentation. Its always a good idea. Hope this helps.

Brendan Green
  • 11,676
  • 5
  • 44
  • 76
vivwilfer
  • 174
  • 4
  • 1
    I've seen this, but I don't think this is what I'm looking for. I was looking for a domain class way, so I don't have to fight everything I'm trying to do. – College Now App Group Apr 11 '15 at 18:18
  • I'm not sure how to use this. It makes you able to select the time and date like I want, but I can't get it to save to the database through gorm. – College Now App Group Apr 11 '15 at 18:37
  • @College Now App Group Well, the params.dateTimeVariable would hold the whole value. However, you can access the values individually. Just print out the parameters and you know what I mean. ` new Date(params.dateTimeVariable)` should do the trick. You can use clearTime to clear the time values if needed. – vivwilfer Apr 12 '15 at 23:07
  • Thanks this worked +1 . I just didn't know where it was located in _form.gsp I was using the create or show.gsp. Now I just need to figure out how to format it when it displays in show. – College Now App Group Apr 13 '15 at 05:09