Recipe Name:
Rewrite getSecondOfMinute() to getSecond()
Description:
Rewrite getSecondOfMinute() to getSecond()
Level:
warning
Language:
  • java
Tags:
  • framework specific
  • java.time
  • Joda-Time
  • quality
Documentation

Joda-Time getField Method names are different in java.time

Some methods names are different in java.time, this recipe provides a fix to rewrite to the new method name.

  • getHourOfDay() has been renamed to getHour()
  • getMinuteOfHour() has been renamed to getMinute()
  • getSecondOfMinute() has been renamed to getSecond()
Recipe
id: scw:java.time:Joda-Time:getSecondOfMinute
version: 10
metadata:
  name: Rewrite getSecondOfMinute() to getSecond()
  shortDescription: Rewrite getSecondOfMinute() to getSecond()
  level: warning
  language: java
  enabled: true
  comment: |-
    The Joda-Time method getSecondOfMinute() is renamed to getSecond() in java.time.
    This recipe provides a transformation to rewrite the method call to the new method name.

    This recipe is designed to match on broken code as part of an overall migration from Joda-Time to java.time.
    After an Joda-Time object has been migrated to a java.time equivalent, some subsequent method calls may become invalid as they are no longer provided by java.time.
    This recipe is designed to match on one of those method calls and provide a fix.
  descriptionFile: descriptions/getMethodRenamed.html
  tags: framework specific;java.time;Joda-Time;quality
search:
  methodcall:
    name: getSecondOfMinute
    anyOf:
    - type: java.time.ZonedDateTime
    - type: java.time.OffsetDateTime
    - type: java.time.LocalDateTime
    - type: java.time.LocalTime
availableFixes:
- name: Rewrite using java.time equivalent getSecond()
  actions:
  - rewrite:
      to: '{{{ qualifier }}}.getSecond()'