解决方式:在接口中定义方法传入参数、返回参数为对一个的类型,mapstruct的实现类会自动调用该方法。
代码:
@Mapper(builder = @Builder(disableBuilder = true)) public interface StlmtCheckingResultConvert { StlmtCheckingResultConvert INSTANCE = Mappers.getMapper(StlmtCheckingResultConvert.class); default LocalDateTime transactionDateToLocalDateTime(final LocalDate transactionDate) { final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); final String transactionDateTimeFormatter = transactionDate.atTime(0, 0, 0, 0).format(dateTimeFormatter); final LocalDateTime transactionDateTime = LocalDateTime.parse(transactionDateTimeFormatter, dateTimeFormatter); return transactionDateTime; }
参考:https://stackoverflow.com/questions/72389940/mapstruct-conversion-from-date-to-localdatetime
标签:类型转换,java,mapstruct,StlmtCheckingResultConvert,dateTimeFormatter,LocalDateTime,L From: https://www.cnblogs.com/wulm/p/18304696