Skip to content

JavaDurationGetSecondsToToSeconds rule is misleading and possibly harmful #5290

@climategadgets

Description

@climategadgets

Expected Behavior

toSeconds() accounts for seconds and nanos, unlike getSeconds(). This is confirmed by AI Overview (screenshot below).

Actual Behavior

toSeconds() is implemented by return seconds; all the way to JDK 25. Hence, getSeconds() and toSeconds() return identical result. The way the rule is phrased may lead the user to believe these results are different and cause errors when a "conversion" is attempted.

Screenshot

Interestingly, this AI Overview seems to be using the JavaDurationGetSecondsToToSeconds rule text to generate the advice, thus possibly creating a circular hallucination.
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions