简体   繁体   中英

Grails Date variable will not set the time

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM