Skip to content

Conversation

@devin-ai-integration
Copy link

Migrate from Joda Time to java.time API (MBA-72)

Summary

This PR implements a complete migration from the deprecated Joda Time library (2.10.13) to the modern java.time API across the entire codebase. The migration replaces DateTime with Instant throughout all layers while maintaining identical functionality, UTC timezone behavior, ISO 8601 serialization format, and cursor-based pagination with millisecond precision.

Key Changes:

  • Dependency: Removed joda-time:2.10.13 from build.gradle
  • Database Layer: Replaced DateTimeHandler with InstantTypeHandler (maintains UTC Calendar usage)
  • Domain Entities: Updated Article and Comment to use Instant instead of DateTime
  • DTOs: Updated ArticleData and CommentData timestamp fields to Instant
  • Cursor Pagination: Migrated DateTimeCursor to use toEpochMilli()/ofEpochMilli() for millisecond serialization
  • Serialization: Updated Jackson serializer to use DateTimeFormatter.ISO_INSTANT (produces identical ISO 8601 format)
  • GraphQL: Updated datafetchers to format timestamps using DateTimeFormatter.ISO_INSTANT
  • Tests: Migrated all test fixtures to use Instant.now() and java.time APIs

Files Changed: 17 files total

  • 1 build config
  • 8 main source files (entities, DTOs, services, serialization, database)
  • 8 test files

Review & Testing Checklist for Human

⚠️ Important: Due to a local Spotless configuration issue with Java module access, I was unable to verify the build locally. CI verification is critical.

  • CI passes completely - Verify all checks pass (compilation, tests, Spotless formatting)
  • API response format unchanged - Test that timestamps in API responses still match the exact format: 2024-01-15T10:30:00.123Z (ISO 8601 with milliseconds and Z suffix)
  • Cursor pagination works - Verify that:
    • Existing cursor tokens from before this migration still work
    • New cursors have identical millisecond-precision format
    • Pagination direction (NEXT/PREV) works correctly
  • Database operations work - Test article/comment CRUD operations to ensure timestamps are correctly persisted and retrieved in UTC
  • End-to-end testing - Run manual tests creating articles/comments and querying by time-based filters to verify behavior is identical to before

Notes

Migration Patterns Used:

  • DateTimeInstant (inherently UTC)
  • new DateTime()Instant.now()
  • getMillis()toEpochMilli()
  • new DateTime(millis)Instant.ofEpochMilli(millis)
  • .minusHours(1).minusSeconds(3600)
  • ISODateTimeFormat.dateTime().withZoneUTC().print()DateTimeFormatter.ISO_INSTANT.format()

Why Instant over LocalDateTime: Instant represents a point in time in UTC, matching the existing Joda DateTime usage with UTC zone. This maintains the UTC-centric architecture without timezone conversion complexity.

Cursor Compatibility: Both Joda's getMillis() and java.time's toEpochMilli() return epoch milliseconds, ensuring cursor backward compatibility.


Link to Devin run: https://app.devin.ai/sessions/936112838b6444758d13944e58f39e4b
Requested by: Daniella Grimberg (@danigrim)
Ticket: MBA-72

- Remove joda-time:2.10.13 dependency from build.gradle
- Replace DateTimeHandler with InstantTypeHandler maintaining UTC behavior
- Update DateTimeCursor to use Instant with toEpochMilli()/ofEpochMilli()
- Migrate Article and Comment entities from DateTime to Instant
- Update ArticleData and CommentData DTOs to use Instant
- Change ArticleQueryService and CommentQueryService to use CursorPageParameter<Instant>
- Update JacksonCustomizations serializer to use DateTimeFormatter.ISO_INSTANT
- Migrate GraphQL datafetchers to use DateTimeFormatter.ISO_INSTANT
- Update all test files to use java.time API

This maintains identical functionality, UTC timezone behavior, ISO 8601
serialization format, and cursor-based pagination with millisecond precision.

Co-Authored-By: Daniella Grimberg <daniella@cognition.ai>
@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

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.

0 participants