Home / Companies / Sonar / Blog / Post Details
Content Deep Dive

The java.time Bugs That Don’t Throw Exceptions

Blog post from Sonar

Post Details
Company
Date Published
Author
Killian Carlsen-Phelan and Jean Jimbo
Word Count
1,450
Company Posts That Month
21
Language
English
Hacker News Points
-
Post removed?
No
Summary

SonarQube's new java.time rules aim to address subtle bugs in Java programming that can lead to incorrect calculations, particularly in the realm of time zones and duration math. These issues often arise when using LocalDateTime for duration calculations across different time zones, leading to plausible yet incorrect results that can affect billing, SLA, and scheduling systems. The rules, such as S8700, flag problematic uses like Duration.between() with LocalDateTime operands, suggesting the use of ZonedDateTime to incorporate time zone differences accurately. Rule S8220 helps prevent runtime exceptions by catching improper LocalDateTime to Instant conversions, while S8692 emphasizes the need for a fixed Clock in tests to ensure deterministic results. Additionally, S8696 addresses the misuse of == for value-based types like Instant, where equals should be used instead. These rules, part of SonarQube's default settings on the cloud and set to ship on the server in version 2026.4, aim to mitigate errors that can pass unnoticed through tests but cause significant downstream impacts.

Trends Found in this Post
Trend Post Mentions Total Month Mentions Posts Companies MoM
AI Coding Assistant 2 2,151 535 165 +20%
AI Agents 1 6,005 1,359 264 +22%
LLM 1 6,196 1,155 243 -32%
Use This Data

Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.