Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6974907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:17:54+00:00 2026-05-27T17:17:54+00:00

I’m having trouble using the JodaTime plugin for Grails. The plugin seems to be

  • 0

I’m having trouble using the JodaTime plugin for Grails. The plugin seems to be correctly converting to JSON for the output, but it does not seem to be able to accept the outputted date format again as input when the same JSON object is sent back in.

These are the errors I get:

Field error in object 'server.Session' on field 'lastUpdated': rejected value [2011-12-19T14:15:03-06:00]; codes [typeMismatch.server.Session.lastUpdated,typeMismatch.lastUpdated,typeMismatch.org.joda.time.DateTime,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [server.Session.lastUpdated,lastUpdated]; arguments []; default message [lastUpdated]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'org.joda.time.DateTime' for property 'lastUpdated'; nested exception is java.lang.IllegalArgumentException: Invalid format: "2011-12-19T14:15:03-06:00" is malformed at "11-12-19T14:15:03-06:00"]
Field error in object 'server.Session' on field 'dateCreated': rejected value [2011-12-19T14:15:03-06:00]; codes [typeMismatch.server.Session.dateCreated,typeMismatch.dateCreated,typeMismatch.org.joda.time.DateTime,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [server.Session.dateCreated,dateCreated]; arguments []; default message [dateCreated]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'org.joda.time.DateTime' for property 'dateCreated'; nested exception is java.lang.IllegalArgumentException: Invalid format: "2011-12-19T14:15:03-06:00" is malformed at "11-12-19T14:15:03-06:00"] id=33 version=0>

Here’s the very basic domain model:

package server

import org.joda.time.DateTime

class Session {

    DateTime dateCreated
    DateTime lastUpdated
    String ip

    static constraints = {
        ip blank: false
    }
}

And here are the show and update methods (send and receive JSON respectively):

def show() {
    def sessionInstance = Session.get(params.id)
    if (!sessionInstance) {
        flash.message = message(code: 'default.not.found.message', args: [message(code: 'session.label', default: 'Session'), params.id])
        redirect(action: "list")
        return
    }

    def response = [sessionInstance: sessionInstance]
    withFormat {
        html response
        json {render response as JSON}
        xml {render response as XML}
    }
}

def update() {

    def sessionInstance = Session.get(params.id)
    if (!sessionInstance) {
        flash.message = message(code: 'default.not.found.message', args: [message(code: 'session.label', default: 'Session'), params.id])
        redirect(action: "list")
        return
    }

    if (params.version) {
        def version = params.version.toLong()
        if (sessionInstance.version > version) {
            sessionInstance.errors.rejectValue("version", "default.optimistic.locking.failure",
                    [message(code: 'session.label', default: 'Session')] as Object[],
                    "Another user has updated this Session while you were editing")
            render(view: "edit", model: [sessionInstance: sessionInstance])
            return
        }
    }

    sessionInstance.properties = params // <----- This is what causes the errors

    log.info("instance: ${sessionInstance.dump()}") // <------ This is where I'm seeing the error messages

    if (!sessionInstance.save(flush: true)) {
        render(view: "edit", model: [sessionInstance: sessionInstance])
        return
    }

    flash.message = message(code: 'default.updated.message', args: [message(code: 'session.label', default: 'Session'), sessionInstance.id])
    redirect(action: "show", id: sessionInstance.id)
}

I’m not sure what I need to do to correct this, or even if I’m doing things correctly, since I’m very new to Grails. In all reality, the two date fields that are causing issues should be handled 100% internally by GORM and I would rather the controller ignore them completely, but there will be other date fields like them that will need to be updated once the domain model gets filled in.

How can I get the automatic JSON unmarshalling to correctly convert back into joda time DateTime objects?

Note: This is currently a proof-of-concept for a client-server application.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T17:17:55+00:00Added an answer on May 27, 2026 at 5:17 pm

    I’m not sure of the cause, nor why this fix works, but adding jodatime.format.html5 = true to the Config.groovy file makes everything work.

    As far as I can tell, there is no change in the JSON output, but for whatever reason, it makes the JSON input handling and data binding work.

    The only semblance of documentation that even hints at this is here.

    Trying to set the format for DateTime via something like jodatime.format.org.joda.time.DateTime = "yyyy-MM-dd'T'HH:mm:ss.SSSZZ" had no effect at all.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.