Recipe Name:
Convert print(Long) to format()
Description:
Convert print(Long) to format()
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-print-long version: 10 metadata: name: Convert print(Long) to format() shortDescription: Convert print(Long) to format() level: error language: java enabled: true comment: "Searches for a print 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: anyOf: - type: long - type: java.lang.Long argCount: 1 name: print type: java.time.format.DateTimeFormatter availableFixes: - name: Change method to format() actions: - rewrite: to: '{{{ qualifier }}}.format(java.time.ZonedDateTime.ofInstant(java.time.Instant.ofEpochMilli({{{ arguments }}}), java.time.ZoneId.systemDefault()))'