GeezerVison is showing github.com — #4027 Fix mapping ZonedDateTime or OffsetDateTime to LocalDateTime by Takch02 · Pull Request #4047 · mapstruct/mapstruct
Conversation
Takch02
commented
May 3, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Fixes #4027
Added implicit conversion support for:
- ZonedDateTime → LocalDateTime (via toLocalDateTime())
- OffsetDateTime → LocalDateTime (via toLocalDateTime())
- LocalDateTime → ZonedDateTime (via atZone(ZoneOffset.UTC))
- LocalDateTime → OffsetDateTime (via atOffset(ZoneOffset.UTC))
- ZonedDateTime → Instant (via toInstant())
- OffsetDateTime → Instant (via toInstant())
- Instant → ZonedDateTime (via atZone(ZoneOffset.UTC))
- Instant → OffsetDateTime (via atOffset(ZoneOffset.UTC))
Changes:
- Added JavaZonedDateTimeToLocalDateTimeConversion
- Added JavaOffsetDateTimeToLocalDateTimeConversion
- Added JavaOffsetDateTimeToInstantConversion
- Added JavaZoneDateTimeToInstantConversion.java
- Added offsetDateTime() helper in ConversionUtils
- Added register() calls in Conversions.java
- Added ZonedOffsetDateTimeToLocalDateTimeConversionTest
- Added fixture for SourceTargetMapperImpl
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…ime/OffsetDateTime and LocalDateTime
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@Takch02 nice implementation.
I see why you assumed that getFromExpression should not be implemented. However, in other conversions we already use ZoneOffset.UTC as a default value, for example in JavaLocalDateToDateConversion and JavaLocalDateToSqlDateConversion.
Could you add the getFromExpression implementation and the according tests?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…ime/OffsetDateTime and LocalDateTime
Takch02
commented
May 23, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
@Takch02 nice implementation. I see why you assumed that getFromExpression should not be implemented. However, in other conversions we already use ZoneOffset.UTC as a default value, for example in JavaLocalDateToDateConversion and JavaLocalDateToSqlDateConversion. Could you add the getFromExpression implementation and the according tests?
@hduelme Thanks for the review! I added getFromExpression and related tests.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@Takch02 the implementation looks clean to me.
Could you add the missing license header to SourceTargetMapperImpl? We ignore license headers in diffs, but we still want every file to include one.
Additionally, @JanecekPetr noticed that mapping to/from Instant is still missing:
Similarly, I now see that neither ZonedDateTime nor OffsetDateTime cannot be converted to Instant at all, even though zonedDateTime.toInstant() exists.
If you'd like, you could implement those mappings as well.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
@Takch02 the implementation looks clean to me. Could you add the missing license header to SourceTargetMapperImpl? We ignore license headers in diffs, but we still want every file to include one.
Additionally, @JanecekPetr noticed that mapping to/from Instant is still missing:
Similarly, I now see that neither ZonedDateTime nor OffsetDateTime cannot be converted to Instant at all, even though zonedDateTime.toInstant() exists.
If you'd like, you could implement those mappings as well.
@hduelme Thank you! l added license headers and conversion Instant/LocalDataTime, Instant/ZoneDateTime
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@Takch02 thanks a lot.
I forgot to mention earlier that built-in conversions are documented in chapter-5-data-type-conversions.asciidoc. Could you also add documentation for the 4 newly added conversions?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Takch02
commented
May 24, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
@Takch02 thanks a lot. I forgot to mention earlier that built-in conversions are documented in chapter-5-data-type-conversions.asciidoc. Could you also add documentation for the 4 newly added conversions?
@hduelme Thank you! I added documentation for the 4 new conversion.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
hduelme
hduelme approved these changes
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|