Skip to content

fix: replaced Date with java.time API#397

Merged
petruki merged 1 commit into
masterfrom
staging
Jun 27, 2026
Merged

fix: replaced Date with java.time API#397
petruki merged 1 commit into
masterfrom
staging

Conversation

@petruki

@petruki petruki commented Jun 27, 2026

Copy link
Copy Markdown
Member

This pull request modernizes the date and time handling throughout the codebase by replacing legacy Date and DateUtils usage with Java 8+ time APIs such as Instant and LocalDateTime. This improves code readability, safety, and future maintainability. It also updates related test code and exception handling to align with the new APIs.

Migration to Java Time API:

  • Replaced Date and DateUtils with Instant, LocalDateTime, and related classes in ClientRemoteService, DateValidator, TimeValidator, SwitcherUtils, and their corresponding test files. This includes updating method signatures, parsing, formatting, and arithmetic operations. [1] [2] [3] [4] [5] [6]

Refactoring and Simplification:

  • Simplified date and time arithmetic in SwitcherUtils.addTimeDuration to use Instant.plus with ChronoUnit instead of Apache Commons methods.
  • Updated date/time comparisons in validators to use isBefore/isAfter methods, improving clarity and type safety. [1] [2]

Test Updates:

  • Refactored tests in SwitcherUtilsTest and MockWebServerHelper to use the new time APIs, ensuring consistency and correctness with the updated implementation. [1] [2] [3]

Exception Handling:

  • Updated exception handling to catch DateTimeParseException instead of ParseException, reflecting the switch to Java time parsing. [1] [2]

Overall, these changes modernize the codebase, reduce external dependencies, and leverage Java's built-in time handling for better reliability and maintainability.

@petruki petruki added this to the v1.10.0 milestone Jun 27, 2026
@petruki petruki self-assigned this Jun 27, 2026
@petruki petruki added enhancement New feature or request ai-assisted Indicates that AI tools were used to assist this with this change labels Jun 27, 2026
@sonarqubecloud

Copy link
Copy Markdown

@petruki petruki merged commit 384ef59 into master Jun 27, 2026
23 of 24 checks passed
@petruki petruki deleted the staging branch June 27, 2026 23:48
petruki added a commit that referenced this pull request Jun 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-assisted Indicates that AI tools were used to assist this with this change enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant