Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds date comparison methods #533

Merged
merged 2 commits into from
Aug 9, 2024
Merged

Adds date comparison methods #533

merged 2 commits into from
Aug 9, 2024

Conversation

idlira
Copy link
Contributor

@idlira idlira commented Aug 8, 2024

Description

Unfortunately Java's standard methods do not provide afterOrEqual or beforeOrEqual, nor a range check.

Note that we are leaving null-handling for the caller to decide, as it strongly depends on usage: am empty date might represent an infinite date in the past or in the future, or represent an exception.

Checklist

  • Code change has been tested and works locally
  • Code was formatted via IntelliJ and follows SonarLint & best practices

@idlira idlira added the 🧬 Enhancement Contains new features label Aug 8, 2024
Copy link
Member

@jakobvogel jakobvogel left a comment

Choose a reason for hiding this comment

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

Reformat and new methods would have been better in two commits. And for the relatively simple methods, is it really worth to use a helper class? (Referring to the use of Range)

@idlira
Copy link
Contributor Author

idlira commented Aug 8, 2024

Reformat and new methods would have been better in two commits. And for the relatively simple methods, is it really worth to use a helper class? (Referring to the use of Range)

Range comes from Google, and we hope to have a better alternative one day. And since we already provide a Dates class, it kinda suits for it.

PS: sorry for the reformat.

@jakobvogel
Copy link
Member

jakobvogel commented Aug 8, 2024

Reformat and new methods would have been better in two commits. And for the relatively simple methods, is it really worth to use a helper class? (Referring to the use of Range)

Range comes from Google, and we hope to have a better alternative one day. And since we already provide a Dates class, it kinda suits for it.

Hmm, for instance, Range.atMost(referenceDate).contains(dateToCheck) should be the same as referenceDate.isAfter(dateToCheck) || referenceDate.isEqual(dateToCheck) if I am not wrong? The Range methods do not seem to support null values and also throw exceptions in such cases. And they allocate an internal object that is likely not required when just comparing the values. Correct me if I am wrong, but I do not see any particular advantage of using Range?

Extending the Dates class is fine, I was only wondering about the use of Range.

@idlira
Copy link
Contributor Author

idlira commented Aug 8, 2024

Hmm, for instance, Range.atMost(referenceDate).contains(dateToCheck) should be the same as referenceDate.isAfter(dateToCheck) || referenceDate.isEqual(dateToCheck) if I am not wrong? The Range methods do not seem to support null values and also throw exceptions in such cases. And they allocate an internal object that is likely not required when just comparing the values. Correct me if I am wrong, but I do not see any particular advantage of using Range?

It was a suggestion from a chat with @sabieber a while ago. I will review that...

@idlira idlira merged commit f187eae into develop Aug 9, 2024
3 checks passed
@idlira idlira deleted the ili/date-goodies branch August 9, 2024 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧬 Enhancement Contains new features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants