Mapstruct LocalDateTime to Instant
问题 I am new in Mapstruct. I have a model object which includes LocalDateTime type field. DTO includes Instant type field. I want to map LocalDateTime type field to Instant type field. I have TimeZone instance of incoming requests. Manually field setting like that; set( LocalDateTime.ofInstant(x.getStartDate(), timeZone.toZoneId()) ) How can I map these fields using with Mapstruct? 回答1: You have 2 options to achieve what you are looking for. First option: Use the new @Context annotation from 1.2