-
-
Notifications
You must be signed in to change notification settings - Fork 2k
[Core] Replace TimeService with Java Time API #1620
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
[Core] Replace TimeService with Java Time API #1620
Conversation
Migrating code to use Java 8 Time API for both Duration and Timestamps. Using Instant and Duration for all instances.
unused import
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.
Looks good to me. The JUnitFormatterTest contains changes in the time formatting. That change is not compatible with the previous behavior.is it correct?
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.
Looks good! I have reviewed about half now. I'll try to do the remainder next week. But feel free to make changes.
core/src/main/java/io/cucumber/core/api/event/TimeStampedEvent.java
Outdated
Show resolved
Hide resolved
Correct. I updated the time formatting to handle for values received from Duration and Instant instead |
I think that's because you no longer divide the nanos? |
Yes you're right. I had updated the formatter to use nanos directly so I updated the tests as well. But I am updating the format back to millis now and adding the division. |
junit/src/test/java/io/cucumber/junit/api/FeatureRunnerTest.java
Outdated
Show resolved
Hide resolved
Looks pretty good so far! I'll need a bit more time to check the details. |
core/src/test/java/io/cucumber/core/plugin/JUnitFormatterTest.java
Outdated
Show resolved
Hide resolved
Looks all good. Cheers! |
Summary
Migrating the current code to use Java 8 Time API fields instead of the currently used primitive fields.
Details
The long fields
time
,timeStampMillis
andduration
have been replaced byInstant
andDuration
respectively.These values can now be used instead of older primitives to allow for better representation of time and duration in cucumber without having to worry about precision or granularity.
Motivation and Context
To allow for more consistent time measurements and reduce custom code.
How Has This Been Tested?
All the JUnits have been updated accordingly to use
Instant
andDuration
.Types of changes
Checklist: