Hello I am using a model mapper to convert from one class to another, I do the mapping at the parent class level and it propagates to the children, but when I get to one of the children, the following happens, the property "dateChange" is mapped correctly to string and with the correct format, but the following property "typeChange" gets the value of date change too and not of "typeChange".
why is it not mapping the bigdecimal correctly? there are more bigdecimal throughout the document and they all map correctly
source class:
public class TipoMoneda {
@XmlElement(name = "Moneda", required = true)
protected String moneda;
@XmlElement(name = "FechaCambio", required = true)
@XmlSchemaType(name = "date")
protected XMLGregorianCalendar fechaCambio;
@XmlElement(name = "TipoCambio", required = true)
protected BigDecimal tipoCambio;
Destination Class:
public class TipoMoneda {
@Schema(description = "Moneda", example = "moneda")
private String moneda;
@Schema(description = "Fecha Cambio", example = "fechaCambio")
private String fechaCambio;
@Schema(description = "Tipo Cambio", example = "tipoCambio")
private String tipoCambio;
also I am using a converter to pass from xmlgregoriancalendar to string, debugging this method is where I have seen the failure.
public SiniestroMapper() {
Converter<XMLGregorianCalendar, String> dateConverter = new Converter<XMLGregorianCalendar, String>() {
@Override
public String convert(MappingContext<XMLGregorianCalendar, String> context) {
if (context.getSource() == null) {
return null;
}
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
return format.format(context.getSource().toGregorianCalendar().getTime());
}
};
this.createTypeMap(XMLGregorianCalendar.class, String.class).setConverter(dateConverter);
}
add some screenshots:
First step:
Second step, when map a date to a worng string


