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

  • Home
  • SEARCH
  • 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 5959579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:42:18+00:00 2026-05-22T18:42:18+00:00

I am having an odd problem in a simple web service built with Spring

  • 0

I am having an odd problem in a simple web service built with Spring 3 and MVC. The web service works ok and I get XML back just like I want, however, all the values for all Joda date/time types are empty.

So I have a UserDTO which is something like this:

@XmlRootElement(name = "user")
public class UserDTO
{
  private String firstname;
  private String lastname;
  private LocalDate birthdate;
  ...

And I have a controller like:

@Controller
public class UserController
{
    @RequestMapping(value = "/user", method = RequestMethod.GET)
    @ResponseBody
    public UserDTO getUser()
    {
        UserDTO userDTO = new UserDTO();
        userDTO.setFirstname("Foo");
        userDTO.setLastname("Bar");
        userDTO.setBirthdate(new LocalDate(1980,1,1));
        return userDTO;
    }
}

I get the following XML back:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<user>
  <firstname>Foo</firstname>
  <lastname>Bar</lastname>
  <birthdate />
</user>

If I change the ‘Accept’ header to application/json, I do get the date value

{“userVO”:{“First Name”,”lastname”:”Last Name”,”birthdate”:[1978,12,5]}}

Any ideas on what this could be?

  • 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-22T18:42:18+00:00Added an answer on May 22, 2026 at 6:42 pm

    To answer my own question… the following link set me on the right path: http://bdoughan.blogspot.com/2011/05/jaxb-and-joda-time-dates-and-times.html

    Basically you have to create an XmlAdapter for each type. Here is an example from the link:

    package blog.jodatime;
    
    import javax.xml.bind.annotation.adapters.XmlAdapter;
    import org.joda.time.DateTime;
    
    public class DateTimeAdapter 
        extends XmlAdapter<String, DateTime>{
    
        public DateTime unmarshal(String v) throws Exception {
            return new DateTime(v);
        }
    
        public String marshal(DateTime v) throws Exception {
            return v.toString();
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having a really odd problem trying to set a simple float value
ok it seems like a simple problem, but i am having problem I have
I am having an odd problem with my SQL Server express 2005 DB. It
I am having a really odd problem with Flash CS4. I have a MovieClip
I'm having a somewhat odd problem with Python(2.6.2) that I've come to the conclusion
I have an odd need to open two separate instances of excel and having
I'm having a rough time with this membership stuff. OK, so, it's really odd.
Having read the threads Is SqlCommand.Dispose enough? and Closing and Disposing a WCF Service
Having a problem getting a TreeView control to display node images. The code below
My program generates relatively simple PDF documents on request, but I'm having trouble with

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.