Skip to content

Conversation

@devin-ai-integration
Copy link

@devin-ai-integration devin-ai-integration bot commented Oct 23, 2025

Phase 3: Migrate from Joda-Time to java.time API

Summary

This PR completes Phase 3 of the Java 17 upgrade by migrating from the legacy Joda-Time library (v2.10.13) to the modern java.time API. All DateTime usages have been replaced with Instant across 17 files, including:

  • Domain models: Article, Comment
  • DTOs: ArticleData, CommentData
  • Infrastructure: MyBatis DateTimeHandler, Jackson serialization
  • Services: ArticleQueryService, CommentQueryService
  • GraphQL: ArticleDatafetcher, CommentDatafetcher
  • Cursor pagination: DateTimeCursor
  • Tests: All test files updated

Additionally, fixed a CI blocker by updating GitHub Actions workflow to use v4 instead of deprecated v2 actions.

Key Technical Changes:

  • DateTimeInstant (UTC-based timestamps)
  • new DateTime()Instant.now()
  • getMillis()toEpochMilli()
  • ISODateTimeFormat.dateTime().withZoneUTC().print()DateTimeFormatter.ISO_INSTANT.format()
  • MyBatis TypeHandler rewritten to use Timestamp.from() / timestamp.toInstant()
  • Removed joda-time:2.10.13 dependency

CI Status: ✅ All checks passing (68 tests, build successful)

Review & Testing Checklist for Human

⚠️ CRITICAL - Serialization Format: The JSON timestamp format changed from Joda-Time's formatter to java.time's DateTimeFormatter.ISO_INSTANT. While both produce ISO 8601, verify:

  • Compare API responses before/after migration to ensure timestamp format is character-for-character identical
  • Check that existing API clients can still parse the timestamps correctly
  • Test edge cases: null timestamps, very old dates, very new dates

⚠️ CRITICAL - Database Layer: The MyBatis DateTimeHandler was completely rewritten:

  • Verify existing articles and comments in the database are still read correctly with their original timestamps
  • Test creating new articles/comments and verify timestamps are persisted correctly
  • Check that database timestamps are still UTC (run a query to inspect raw values)

⚠️ HIGH - Cursor Pagination: DateTimeCursor parsing logic changed:

  • Test pagination with cursor values from before this migration (backwards compatibility)
  • Test pagination end-to-end: fetch page 1, use cursor to fetch page 2, verify correct results
  • Test edge cases: invalid cursors, null cursors, cursor at boundaries

Recommended End-to-End Test Plan:

  1. Deploy to staging/test environment
  2. Run existing integration tests against the deployed instance
  3. Use actual API client (Postman/curl) to create articles and comments
  4. Verify timestamps in responses match expected ISO 8601 format
  5. Query database directly to verify persisted timestamp values
  6. Test pagination flows with cursors
  7. Monitor for any errors or unexpected behavior

Notes

Environment Issue - Spotless Formatting: There's an unresolved issue with the Google Java Format plugin (incompatible with Java 17). The code itself is correct and passes all tests, but may not follow the project's formatting standards. This is an environment configuration issue that needs to be addressed separately.

Regex Patterns: Verified that existing regex patterns (e.g., Article.toSlug()) are Java 17 compatible - no changes needed.

Session Info:

- Replace DateTime with Instant across all domain classes, DTOs, and services
- Update MyBatis DateTimeHandler to work with Instant and SQL Timestamps
- Update Jackson serialization to use DateTimeFormatter.ISO_INSTANT
- Update GraphQL datafetchers to format Instant with ISO_INSTANT
- Update DateTimeCursor for cursor-based pagination with Instant
- Update all test files to use java.time instead of Joda-Time
- Remove joda-time:2.10.13 dependency from build.gradle

All datetime operations remain UTC-based as before. Instant provides
the same semantics as DateTime for UTC timestamp handling.

All 68 tests pass successfully. Build completes without errors.

Co-Authored-By: Alex Peng <alexander.j.peng@gmail.com>
@devin-ai-integration
Copy link
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

- Update actions/checkout from v2 to v4
- Update actions/setup-java from v2 to v4
- Update actions/cache from v2 to v4

This fixes the CI failure caused by deprecated actions/cache@v2 which
was automatically failing as of December 2024.

Co-Authored-By: Alex Peng <alexander.j.peng@gmail.com>
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.

1 participant