Skip to content

DO NOT MERGE! example implementation of binding java.time types#5022

Closed
ewaterman wants to merge 2 commits intodevelopfrom
ft/OBPIH-6965-sample-usage
Closed

DO NOT MERGE! example implementation of binding java.time types#5022
ewaterman wants to merge 2 commits intodevelopfrom
ft/OBPIH-6965-sample-usage

Conversation

@ewaterman
Copy link
Member

@ewaterman ewaterman commented Jan 31, 2025

DO NOT MERGE!

This PR is an example implementation of how we could use the new java.time classes in our domain objects.

PR that adds data binding support of Instant and LocalDate: #5023

The main piece of information here is TestingDatesApiSpec, which I've commented on explaining the drawbacks of java.util.Date, mainly around the timezone that it defaults to. I also demonstrate how Instant and LocalDate fix the issue.

Feel free to leave comments here as well.

Once my other PR gets merged, I'll close this one. I only created it so we'd have something to reference when reviewing the other PR.

@ewaterman ewaterman added the warn: do not merge Marks a pull request that is not yet ready to be merged label Jan 31, 2025
@ewaterman ewaterman self-assigned this Jan 31, 2025
@github-actions github-actions bot added type: feature A new piece of functionality for the app domain: backend Changes or discussions relating to the backend server flag: schema change Hilights a pull request that contains a change to the database schema flag: config change Hilights a pull request that contains a change to the app config labels Jan 31, 2025
// WE SHOULD BE DOING THIS! I commented it out though because it has big implications for everywhere else that
// we parse in dates. We should definitely review this though. Without it, the default timezone that we parse
// dates to will change depending on where the app is hosted.
// TimeZone.setDefault(TimeZone.getTimeZone(ZoneOffset.UTC))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably worth discussion

givenDate || expectedResult | expectedToStringResult | scenario
// See how we input no tz information, but the server decides to treat it as local time (which for me currently
// is CST). If someone runs this test against a server in a different tz, it'll fail. Bad!
// To fix this, we need to add "TimeZone.setDefault(TimeZone.getTimeZone(ZoneOffset.UTC))" to BootStrap.groovy
Copy link
Member Author

@ewaterman ewaterman Jan 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This scenario is demonstrable right here in this PR. The tests fail in the GitHub Action because the Action runner is running in a different timezone than I am (UTC). https://github.com/openboxes/openboxes/actions/runs/13077910108/job/36494469201?pr=5022#step:4:13857

Base automatically changed from ft/OBPIH-6965-support-binding-java-time-types to develop February 12, 2025 15:41
@ewaterman ewaterman closed this Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: backend Changes or discussions relating to the backend server flag: config change Hilights a pull request that contains a change to the app config flag: schema change Hilights a pull request that contains a change to the database schema type: feature A new piece of functionality for the app warn: do not merge Marks a pull request that is not yet ready to be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant