Skip to content

[java] new "ReplaceJavaUtilDate" and "ReplaceJavaUtilCalendar" trigger for SQL classes #6025

Open

Description

@hgschmie

Yes, I am fully aware of #5966 and I read the rationale there.

Java 24 (latest release) and Java 25 (upcoming LTS) both ship with JDBC 4.3. The cited "JPA 3.2" package is an additional part of JEE which most users will not have (and it is not even clear that database drivers will support this).

Jakarta Persistence is not the JDBC spec. Skimming release notes for keywords makes no sense. So a consumer of the JDBC spec, JPA no longer supports java.sql.Date. That does not mean that it is no longer supported by the JDBC spec or that there is a replacement in the JDBC spec (there is not).

Unconditionally claiming that "users need to update" but in case of the java.sql classes, there is no replacement available within the JDK. The whole argument is based on a misread what JPA actually is.

I can see the case for java.util.* as java.time has been around since JDK 8 but I would like to either have a switch that turns off the warning for java.sql or ignore java.sql altogether. The current state simply makes me turn off the rule completely.

Activity

  1. added
    a:bug
    on Aug 30, 2025
  2. changed the title [-]new "ReplaceJavaUtilDate" and "ReplaceJavaUtilCalendar" trigger for SQL classes[/-] [+][java] new "ReplaceJavaUtilDate" and "ReplaceJavaUtilCalendar" trigger for SQL classes[/+] on Sep 1, 2025
  3. mrclmh commented on Nov 21, 2025

    @mrclmh
    Contributor

    I see the case for java.sql.* being a valid exception to the rule. For the time being, something like this could be used as a workaround.

    <rule ref="category/java/errorprone.xml/ReplaceJavaUtilDate">
        <properties>
            <property name="violationSuppressXPath" value=".[pmd-java:typeIs('java.sql.Date') or pmd-java:typeIs('java.sql.Time') or pmd-java:typeIs('java.sql.Timestamp')]"/>
        </properties>
    </rule>
  4. rturner-edjuster commented on Jan 8, 2026

    @rturner-edjuster

    Corrected rule:

    <rule ref="category/java/errorprone.xml/ReplaceJavaUtilDate">
        <properties>
            <property name="violationSuppressXPath" value=".[ClassType[pmd-java:typeIs('java.sql.Date')] or ClassType[pmd-java:typeIs('java.sql.Time')] or ClassType[pmd-java:typeIs('java.sql.Timestamp')]]"/>
        </properties>
    </rule>
  5. added a commit that references this issue on Aug 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions