황현정
황현정

Reputation: 3531

Time format/picker in Grails?

I have a domain class called schedule. It has the following fields:

String timeStart
String timeEnd
Date date
String timeZone

I want to know, what datatype should be used for time. I think, Date should be enough but I want a to separate it from the time, so how should I go about that. I just want to extract this part: MM/DD/YY...

In the views, is there some kind of plugin or tag that can be used for the time alone? Like, a couple of combo boxes that can allow the user to select an hour, minutes, and probably AM or PM? I can do it manually, but a plugin would be nice... :)

The current plugin I'm looking into right now is: http://www.grails.org/plugin/calendar

Upvotes: 3

Views: 3395

Answers (1)

moritz
moritz

Reputation: 5234

If you can choose I would go with Joda Time via the joda time plugin. Joda time is a MUCH BETTER replacement for java.date and calendar.

Then your domain classes for a schedular would become something like this:

class Schedule {
    static hasMany = [appointments:Appointment]
}

class Appointment {
    DateTime start
    DateTime end
    other properties e.g. name, description...
}

The timezone and date data is all in the DateTime object.

Upvotes: 4

Related Questions