-
Notifications
You must be signed in to change notification settings - Fork 151
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
Conversation
…te Timestamps and java.util.Date code.
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! |
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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 😉
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
final LocalDate from = now.minusYears(18).toLocalDate(); | ||
final LocalDate to = now.minusYears(65).toLocalDate(); |
There was a problem hiding this comment.
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?
@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. |
…te Timestamps and java.util.Date code.
Should address #1183