Recipe Name:
Convert field to java.time.DateTimeFormatter
Description:
Convert field to java.time.DateTimeFormatter
Level:
warning
Language:
  • java
Tags:
  • framework specific
  • java.time
  • Joda-Time
  • quality
Documentation

Migrate from org.joda.time.DateTimeFormatter to Java Time

Joda-Time DateTimeFormatter migrates to java.time DateTimeFormatter.

It's a same concept, an immutable formatter

Before
    DateTimeFormatter dtf = DateTimeFormat.fullDate();
After
    java.time.format.DateTimeFormatter dtf = java.time.format.DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL);
References
Recipe
id: scw:java.time:Joda-Time:datetimeformatter-field
version: 10
metadata:
  name: Convert field to java.time.DateTimeFormatter
  shortDescription: Convert field to java.time.DateTimeFormatter
  level: warning
  language: java
  enabled: true
  comment: |-
    Searches for a field of org.joda.time.format.DateTimeFormatter and provides fixes to migrate to a java.time equivalent.

    This recipe will cause broken code as part of an overall number of steps to perform a migration of Joda-Time to java.time.

    After migrating this instance creation to the java.time equivalent, subsequent method calls and usages of the instance may become invalid.
    Further Sensei recipes are available to help resolve many of these invalid usages.
  descriptionFile: descriptions/datetimeformatter.html
  tags: framework specific;java.time;Joda-Time;quality
search:
  field:
    type: org.joda.time.format.DateTimeFormatter
availableFixes:
- name: Use java.time DateTimeFormatter
  actions:
  - changeType:
      type: java.time.format.DateTimeFormatter