I'm trying to convert an object using a mapper with Mapstruct that has a Date (java.util.Date) field to an object with a LocalDateTime field. The problem is that it maps the time wrong because in the object with the LocalDateTime field it always says 2 hours less.
@Mapping(source = "createdDate", target = "createdLocalDateTime")
ObjectA toEntity(ObjectB);
I think that the problem is the auto implementation:
if ( createdDate!= null ) {
objectA.createdLocalDateTime( LocalDateTime.ofInstant( createdDate.toInstant(), ZoneId.of( "UTC" ) ) );
}
How can I fix this? Thanks!