Skip to content

DJ-73: migrate backend off joda-time to java.time and show relative timestamps in the frontend - #212

Open
devin-ai-integration[bot] wants to merge 7 commits into
mainfrom
devin/dj73-joda-to-javatime-relative-timestamps
Open

DJ-73: migrate backend off joda-time to java.time and show relative timestamps in the frontend#212
devin-ai-integration[bot] wants to merge 7 commits into
mainfrom
devin/dj73-joda-to-javatime-relative-timestamps

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Summary

Removes the deprecated joda-time dependency from the backend (migrating to java.time.Instant) and replaces the frontend's static toDateString() timestamps with relative times plus a full-date tooltip. DJ-73.

The constraint that shaped the backend work: the API date contract had to stay byte-identical. Joda's ISODateTimeFormat.dateTime().withZoneUTC() always emits 3-digit millis (2026-07-29T20:57:31.000Z), while Instant.toString() drops trailing-zero millis (...31Z), so every serialization path goes through one explicit formatter instead:

// io.spring.application.DateTimeFormats
public static final DateTimeFormatter DATE_TIME_FORMAT =
    DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").withZone(ZoneOffset.UTC);

used by JacksonCustomizations.DateTimeSerializer (now StdSerializer<Instant>) and by both GraphQL datafetchers, replacing the per-call ISODateTimeFormat...print(...). Everything else is a type swap: Article/Comment/ArticleData/CommentData fields, CursorPageParameter<DateTime><Instant>, and DateTimeHandler becomes TypeHandler<Instant> (@MappedTypes(Instant.class)) keeping the identical UTC-Calendar/Timestamp round-trip. DateTimeCursor keeps emitting raw epoch millis (getMillis()toEpochMilli(), new DateTime().withMillis(x)Instant.ofEpochMilli(x)).

Frontend adds frontend/lib/utils/relativeTime.ts — no new runtime deps, just Intl.RelativeTimeFormat — exporting getRelativeTime(iso, now?) (largest sensible unit, "just now" under 10s, "" for invalid/empty input) and getFullDate(iso) for the tooltip:

- <span className="date">{new Date(preview.createdAt).toDateString()}</span>
+ <span className="date" title={getFullDate(preview.createdAt)}>
+   {getRelativeTime(preview.createdAt)}
+ </span>

ArticleType.createdAt/updatedAt were typed number while the API has always returned ISO strings; corrected to string.

TypeScript moves ^3.9.74.9.5 because Intl.RelativeTimeFormat typings don't exist before 4.1 — on 3.9.10 the build fails with error TS2339: Property 'RelativeTimeFormat' does not exist on type 'typeof Intl'. jest/ts-jest/@types/jest are added as dev deps for the new unit tests.

Tests

New unit tests: DateTimeFormatsTest (asserts whole-second instants serialize as ...:31.000Z, not ...:31Z, plus a .123Z case, over both the Jackson and datafetcher paths), DateTimeCursorTest (cursor string == epoch millis, encode→decode round-trip), DateTimeHandlerTest (symmetric UTC Timestamp conversion), and frontend/lib/utils/relativeTime.test.ts (17 cases: every unit boundary, the exact .000Z API format, future dates, invalid/empty input, tooltip helper).

Verification: ./gradlew clean test spotlessCheck passes (72 tests, 0 failures; jacocoTestCoverageVerification fails at 0.33 vs 0.80 both here and on unmodified main, so it is pre-existing and untouched). Frontend: npm test 17/17, npx tsc --noEmit clean, next build compiles. grep -rn joda src/ build.gradle is empty.

Live check against the running app — curl http://localhost:8080/articles still returns "createdAt":"2026-07-29T21:26:19.000Z", matching ^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$ for every article, same field shape as the pre-migration capture.

Home feed: before / after

Before (static dates) After (relative times)
before after

Full date on hover:

tooltip

Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/6c3903acf9244ec4b20cd69300aede02
Requested by: @HJscarr

@HJscarr HJscarr self-assigned this Jul 30, 2026
@devin-ai-integration

Copy link
Copy Markdown
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, CI, and merge conflict 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.

1 participant