GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — #4027 Fix mapping ZonedDateTime or OffsetDateTime to LocalDateTime by Takch02 · Pull Request #4047 · mapstruct/mapstruct

Conversation

@Takch02

@Takch02 Takch02 commented May 3, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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.

All reactions
Takch02 added 2 commits May 3, 2026 13:51
@Takch02
mapstruct#4027 Add support for implicit conversion between ZonedDateT…
d985b9c
…ime/OffsetDateTime and LocalDateTime
@Takch02
mapstruct#4027 Add fixture for SourceTargetMapperImpl
f492c3b
@Takch02

Takch02 commented May 3, 2026

Copy link
Copy Markdown
Contributor Author

@filiphr @JanecekPetr Please Review! Thank you.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Takch02
mapstruct#4027 Add license Header
f0279a9
@hduelme

hduelme commented May 22, 2026

Copy link
Copy Markdown
Contributor

@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?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Takch02
mapstruct#4027 Add support for implicit conversion between ZonedDateT…
7fe6088
…ime/OffsetDateTime and LocalDateTime
@Takch02

Takch02 commented May 23, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

@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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hduelme

hduelme commented May 23, 2026

Copy link
Copy Markdown
Contributor

@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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Takch02
mapstruct#4027 Add support for conversion Instant/LocalDateTime, Inst…
5fda707
…ant/ZoneDateTime
@Takch02

Takch02 commented May 23, 2026

Copy link
Copy Markdown
Contributor Author

@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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hduelme

hduelme commented May 23, 2026

Copy link
Copy Markdown
Contributor

@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?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Takch02
mapstruct#4027 Add documentation
db58594
@Takch02

Takch02 commented May 24, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

@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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

hduelme
hduelme approved these changes May 24, 2026
View reviewed changes
@hduelme
hduelme merged commit 428fd27 into mapstruct:main May 24, 2026
9 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@hduelme

hduelme commented May 24, 2026

Copy link
Copy Markdown
Contributor

@Takch02 thanks again. Its now merged.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Takch02

Takch02 commented May 24, 2026

Copy link
Copy Markdown
Contributor Author

@hduelme Thank you!!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Takch02
Takch02 deleted the feature/4027-zoned-to-local-datetime branch May 25, 2026 04:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@hduelme hduelme hduelme approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Mapping ZonedDateTime or OffsetDateTime to LocalDateTime

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@Takch02 @hduelme
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.