Recipe Name:
Convert printTo() to formatTo()
Description:
Convert printTo() to formatTo()
Level:
error
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
BeforeDateTimeFormatter 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-printto-appendable-readable version: 10 metadata: name: Convert printTo() to formatTo() shortDescription: Convert printTo() to formatTo() level: error language: java enabled: true comment: "Searches for a printTo method called and provides fixes to migrate to a java.time equivalent.\n\nThis recipe is designed to match on broken code. This method originally was called by org.joda.time.format.DateTimeFormatter type, \nhowever this object type should first be migrated to java.time.format.DateTimeFormatter using the other migration recipes.\nThis recipe will then match on the broken code, and the fixes in this recipe will allow the completion of the migration." descriptionFile: descriptions/datetimeformatter.html tags: framework specific;java.time;Joda-Time;quality search: methodcall: args: 1: type: java.lang.Appendable 2: anyOf: - type: org.joda.time.ReadablePartial - type: org.joda.time.ReadableInstant - type: java.time.temporal.TemporalAccessor argCount: 2 name: printTo type: java.time.format.DateTimeFormatter availableFixes: - name: Rewrite to .format(TemporalAccessor, Appendable) actions: - rewrite: to: '{{{ qualifier }}}.formatTo({{{ arguments.1 }}}, {{{ arguments.0 }}})'