Skip to content

Conversation

@amishra-u
Copy link
Contributor

What's changed?

Added migration templates to convert Joda-Time Interval classes to the ThreeTen-extra Interval. The Interval class is not part of the JDK but is implemented in ThreeTen-extra, built on top of Java's java.time classes. This change include migration templates for methods from the following Joda-Time classes:

  1. org.joda.time.Interval
  2. org.joda.time.AbstractInterval

What's your motivation?

Increase coverage for Joda-Time to Java Time migration recipe by adding support for additional classes.

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

Copy link
Member

@timtebeek timtebeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great to see! the only thing I'm wondering is if there should be a declarative recipe to add that threeten-extra dependency if not already present (transitively). Just to ensure there's no compilation failures due to a missing dependency after the migration.

import static org.openrewrite.java.Assertions.*;
import static org.openrewrite.maven.Assertions.pomXml;

public class NoJodaTimeTest implements RewriteTest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public class NoJodaTimeTest implements RewriteTest {
class NoJodaTimeTest implements RewriteTest {

@amishra-u
Copy link
Contributor Author

amishra-u commented Dec 4, 2024

Great to see! the only thing I'm wondering is if there should be a declarative recipe to add that threeten-extra dependency if not already present (transitively). Just to ensure there's no compilation failures due to a missing dependency after the migration.

I’ve added a declarative recipe with AddDependency. Also added test.

Copy link
Member

@timtebeek timtebeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot once again!

@timtebeek timtebeek merged commit 3b3f34f into openrewrite:main Dec 4, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants