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

Migrated DateAndTime to TimeAndDate to support Java8 Time, and depreca… #1210

Merged
merged 4 commits into from
May 25, 2024

Conversation

bodiam
Copy link
Contributor

@bodiam bodiam commented May 25, 2024

…te Timestamps and java.util.Date code.

Should address #1183

@kingthorin
Copy link
Collaborator

Ugh, just one minor comment. Apparently I was half asleep and set approve anyway 🤷‍♂️

@bodiam
Copy link
Contributor Author

bodiam commented May 25, 2024

Ugh, just one minor comment. Apparently I was half asleep and set approve anyway 🤷‍♂️

Appreciate the approval, I fixed the naming, and a few other minor improvements. If you want to have another look, that would be great!

Copy link
Collaborator

@kingthorin kingthorin left a comment

Choose a reason for hiding this comment

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

Sorry found a few more minor things. Feel free to merge after these 😁

* @return a random birthday between {@code minAge} and {@code maxAge} years ago from now.
* Negative {@code minAge} and {@code maxAge} are supported.
*/
public LocalDate birthday(int minAge, int maxAge) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Make sure they're not negative or zero?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Make sure they're not negative or zero?

Not sure, since "Negative {@code minAge} and {@code maxAge} are supported.". ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Okay, wasn't sure that was intentional.

Instant now = Instant.now();
Instant future = timeAndDate.future(5, 4, TimeUnit.SECONDS);
assertThat(future)
.isBetween(now.plusMillis(3500), now.plusMillis(5500));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Make constants for these magic numbers or add a comment that clarifies. I'm sure it makes sense if I read the code but less digging is better 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, but I mostly ported the old code to the new types. I'll have a look later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is actually great feedback. I'm reading this code now, and to me, it doesn't really make sense. Why are 5 and 4 flipped around? It would make more sense to me to have a future date between 4 and 5 seconds into the future, not between 5 and 4. What do you think? (the challenge is that the behaviour of this method would be slightly different from the old one, so maybe this should throw an exception if argument 2 is lower than argument 1? Thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hahaha I was actually on about the 3500 & 5500.

But ya I agree changing the item you're talking about seems better too and enforcing the condition as well.

Comment on lines +110 to +111
final LocalDate from = now.minusYears(18).toLocalDate();
final LocalDate to = now.minusYears(65).toLocalDate();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use the constants from the new class?

@bodiam bodiam merged commit 8b25a29 into main May 25, 2024
10 checks passed
@bodiam bodiam deleted the datetime8 branch May 25, 2024 14:55
@bodiam
Copy link
Contributor Author

bodiam commented May 25, 2024

@kingthorin I've merged this PR, but I will take your feedback into account. Only reason I merged is so I can ask @asolntsev to use this faker instead in the other PR.

@bodiam bodiam changed the title Migrated DateAnTime to TimeAndDate to support Java8 Time, and depreca… Migrated DateAndTime to TimeAndDate to support Java8 Time, and depreca… May 25, 2024
@asolntsev asolntsev mentioned this pull request May 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants