karruma
karruma

Reputation: 768

Marshalling Joda LocalTime in Grails

I am trying to marshall an object that contains LocalTime joda type time. And the problem occurs if you try to return a time that is later than 12am, so in the example below if the start of a lesson is 14:00 (2pm) then the time is converted to 02:00 and not 14:00 in the specified format (hh:mm).

So my BootStrap.groovy file contains following code:

   JSON.registerObjectMarshaller(Lesson) {
    def returnArray = [:]
    returnArray['start'] = it.start.toString("hh:mm")
    return returnArray
   }

Any idea how to fix it?

Thanks,

Upvotes: 0

Views: 497

Answers (1)

sbglasius
sbglasius

Reputation: 3124

Well, to get a 24 hrs format you need HH:mm, that's why you get 02:00 instead of 14:00

Upvotes: 1

Related Questions