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, c
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:
org.joda.time.DateTime
org.joda.time.DateTime
and
public class DateTimeCustomConverter extends DozerConverter {
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 :)