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 8428343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:01:43+00:00 2026-06-10T05:01:43+00:00

I am using Dozer to map between a Document class to DocumentManagementBean class, both

  • 0

I am using Dozer to map between a Document class to DocumentManagementBean class, both of my own making. Both have a property, with getters and setters, of Joda DateTime type, called dateAdded.

When Document object d has property dateAdded=x, calling mapper.map(d, DocumentManagementBean.class) all fields get auto-mapped correctly (since I have full control over code base I am able to get away with no dozer-config and rely simply on matching property names), EXCEPT the dateAdded field, where the new DocumentManagementBean dmb ends up with the current DateTime in its dateAdded property, instead of x from the d object.

I am expecting Dozer to try to call

dmb.setDateAdded(d.getDateAdded());

and just bring the value of dateAdded from source to target, but it seems to be creating new DateTime for dmb object an then leaving it alone.

Can anyone shed some light on this for me please?

  • 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-06-10T05:01:45+00:00Added an answer on June 10, 2026 at 5:01 am

    The basic problem is that Dozer creates a new blank instance of DateTime, via new DateTime(), and thats how you end up with the current date/time instead of the original one. There might be multiple solutions, I usually went with a customconverter, globally defined:

        <converter type="de.kba.resper.customconverter.DateTimeCustomConverter">
            <class-a>org.joda.time.DateTime</class-a>
            <class-b>org.joda.time.DateTime</class-b>
        </converter>
    

    and

    public class DateTimeCustomConverter extends DozerConverter<DateTime, DateTime> {
    
        public DateTimeCustomConverter() {
            super(DateTime.class, DateTime.class);
        }
    
        @Override
        public DateTime convertTo(final DateTime source, final DateTime destination) {
    
            if (source == null) {
                return null;
            }
    
            return new DateTime(source);
        }
    
        @Override
        public DateTime convertFrom(final DateTime source, final DateTime destination) {
    
            if (source == null) {
                return null;
            }
    
            return new DateTime(source);
            }
    
    }
    

    It may overdo it, though 🙂

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

Sidebar

Related Questions

I am currently using Dozer to map to sets of objects. I have a
I'm using Dozer to map Hibernate entities to their DTOs. A simplified example class
I need to map class A into class C using dozer framework. public class
Quick question: I'm using Dozer to make mappings between two different classes. In my
I am trying to use Dozer Java API to map two java classes using
i am using half dozen jquery plugins and plus my own jquery scripts and
I have a class that has more than a dozen properties. For most of
Using CakePHP, I am finding that I'm duplicating some code between controller actions. I
I need to build an XML document from a Java object hierarchy. Both the
I'm using a great jQuery plugin called GMaps3 to display a map on a

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.