Inspectopedia
 
2024.3

Redundant operation on 'java.time' object

Warning
New
Last modified: 03 December 2024

Reports redundant operation on 'java.time' object redundant:

  • creation of date/time objects from the JDK java.time package when simpler method calls can be used or creation can be avoided.

  • java.time method calls with java.time.temporal.ChronoField and java.time.temporal.ChronoUnit as arguments when these calls can be replaced with calls of more specific methods.

  • java.time comparisons with compareTo() calls that can be replaced with isAfter(), isBefore() or isEqual() calls.

Examples:

- Before:

After the quick-fix is applied:

- Before:

After the quick-fix is applied:

- Before:

After the quick-fix is applied:

New in 2024.3