Prefer the Java standard library instead of Joda-Time

MSAL

Before Java 8, Java lacked a robust date and time library, leading to the widespread use of Joda-Time to fill this gap. With the release of Java 8, the java.time package was introduced, incorporating most of Joda-Time's concepts. Features deemed too specialized or bulky for java.time were included in the ThreeTen-Extra library. This recipe migrates Joda-Time types to java.time and threeten-extra types.

org.openrewrite.java.joda.time.NoJodaTime
mod run . --recipe=org.openrewrite.java.joda.time.NoJodaTime

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.

Recipe list

It runs these recipes, in this order.

  1. Add Gradle or Maven dependency org.threeten:threeten-extra:1.8.0
  2. Change method name org.joda.time.base.AbstractDateTime getHourOfDay() to getHour
  3. Change method name org.joda.time.base.AbstractDateTime getMinuteOfHour() to getMinute
  4. Change method name org.joda.time.base.AbstractDateTime getSecondOfMinute() to getSecond
  5. Change method name org.joda.time.base.AbstractDateTime getMonthOfYear() to getMonthValue
  6. Change method name org.joda.time.DateTime withZone(org.joda.time.DateTimeZone) to withZoneSameInstant
  7. Change method name org.joda.time.DateTime withZoneRetainFields(org.joda.time.DateTimeZone) to withZoneSameLocal
  8. Change method name org.joda.time.DateTime withMonthOfYear(int) to withMonth
  9. Change method name org.joda.time.DateTime withHourOfDay(int) to withHour
  10. Change method name org.joda.time.DateTime withMinuteOfHour(int) to withMinute
  11. Change method name org.joda.time.DateTime withSecondOfMinute(int) to withSecond
  12. Change method name org.joda.time.Duration standardDays(long) to ofDays
  13. Change method name org.joda.time.Duration standardHours(long) to ofHours
  14. Change method name org.joda.time.Duration standardMinutes(long) to ofMinutes
  15. Change method name org.joda.time.Duration standardSeconds(long) to ofSeconds
  16. Change method name org.joda.time.Duration millis(long) to ofMillis
  17. Change method name org.joda.time.Duration getStandardDays() to toDays
  18. Change method name org.joda.time.Duration getStandardHours() to toHours
  19. Change method name org.joda.time.Duration getStandardMinutes() to toMinutes
  20. Change method name org.joda.time.Duration getStandardSeconds() to getSeconds
  21. Change method name org.joda.time.DateTimeZone forID(String) to of
  22. Change method name org.joda.time.Instant getMillis() to toEpochMilli
  23. Change method name org.joda.time.base.BaseDuration getMillis() to toMillis
  24. Change method name org.joda.time.ReadableDuration getMillis() to toMillis
  25. Change method name org.joda.time.LocalDate getMonthOfYear() to getMonthValue
  26. Change method name org.joda.time.LocalDate withMonthOfYear(int) to withMonth
  27. Change method name org.joda.time.LocalTime getHourOfDay() to getHour
  28. Change method name org.joda.time.LocalTime getMinuteOfHour() to getMinute
  29. Change method name org.joda.time.LocalTime getSecondOfMinute() to getSecond
  30. Change method name org.joda.time.LocalTime withHourOfDay(int) to withHour
  31. Change method name org.joda.time.LocalTime withMinuteOfHour(int) to withMinute
  32. Change method name org.joda.time.LocalTime withSecondOfMinute(int) to withSecond
  33. Migrate Joda-Time DateTime to java.time.ZonedDateTime
  34. Migrate Joda-Time AbstractInstant to Java time
  35. Migrate Joda-Time Duration to Java time
  36. Migrate Joda-Time Interval to Java time
  37. Migrate Joda-Time LocalDate to java.time.LocalDate
  38. Migrate Joda-Time LocalTime to java.time.LocalTime
  39. Migrate Joda-Time formatter to Java time
  40. Migrate Joda-Time property idioms to Java time
  41. Migrate Joda-Time DateTimeZone to Java time
  42. Migrate Joda-Time DateMidnight to Java time
  43. Migrate Joda-Time Instant to Java time
  44. Migrate Joda-Time Days, Hours, Minutes, Seconds to Java time
  45. Change type DateTime to ZonedDateTime
  46. Change type ReadableDateTime to ZonedDateTime
  47. Change type BaseDateTime to ZonedDateTime
  48. Change type AbstractDateTime to ZonedDateTime
  49. Change type DateTimeZone to ZoneId
  50. Change type org.joda.time.format.DateTimeFormatter to java.time.format.DateTimeFormatter
  51. Change type DateTimeFormat to DateTimeFormatter
  52. Change type org.joda.time.Duration to java.time.Duration
  53. Change type ReadableDuration to Duration
  54. Change type BaseDuration to Duration
  55. Change type AbstractDuration to Duration
  56. Change type org.joda.time.Instant to java.time.Instant
  57. Change type AbstractInstant to Instant
  58. Change type ReadableInstant to Instant
  59. Change type org.joda.time.Interval to org.threeten.extra.Interval
  60. Change type ReadableInterval to Interval
  61. Change type BaseInterval to Interval
  62. Change type AbstractInterval to Interval
  63. Change type DateMidnight to ZonedDateTime
  64. Change type org.joda.time.LocalDate to java.time.LocalDate
  65. Change type org.joda.time.LocalTime to java.time.LocalTime
  66. Change type org.joda.time.LocalDateTime to java.time.LocalDateTime