Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1/x] Implement joda to java time migration recipe #567

Merged
merged 18 commits into from
Oct 4, 2024

Conversation

amishra-u
Copy link
Contributor

What's changed?

This pr is the first part of implementing the migration from Joda-Time to the Java Time API. The focus of this PR is to introduce templates for migrating key methods within the DateTime class and other related classes from Joda-Time to Java Time.

Key Changes:

  • Added templates to handle the migration of most method invocations from Joda-Time's DateTime class to corresponding methods in the Java Time API.
  • Implemented JodaTimeVisitor to migrate MethodInvocation and NewClass expressions from Joda-Time to Java Time.

Not Implemented Yet:

Migrations for expressions referencing variables of Joda-Time types are currently skipped. The logic to migrate variables and expressions referencing Joda-Time classes will be added in a follow-up PR.

Checklist

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

import static org.openrewrite.java.Assertions.java;
import static org.openrewrite.test.RewriteTest.toRecipe;

public class JodaTimeVisitorTest 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 JodaTimeVisitorTest implements RewriteTest {
class JodaTimeVisitorTest implements RewriteTest {

@timtebeek timtebeek self-requested a review October 4, 2024 11:27
sambsnyd and others added 2 commits October 4, 2024 10:11
…r.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Comment on lines 24 to 26
import static org.openrewrite.java.migrate.joda.templates.TimeClassNames.JAVA_ZONE_ID;
import static org.openrewrite.java.migrate.joda.templates.TimeClassNames.JAVA_ZONE_OFFSET;
import static org.openrewrite.java.migrate.joda.templates.TimeClassNames.JODA_DATE_TIME_ZONE;
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
import static org.openrewrite.java.migrate.joda.templates.TimeClassNames.JAVA_ZONE_ID;
import static org.openrewrite.java.migrate.joda.templates.TimeClassNames.JAVA_ZONE_OFFSET;
import static org.openrewrite.java.migrate.joda.templates.TimeClassNames.JODA_DATE_TIME_ZONE;
import static org.openrewrite.java.migrate.joda.templates.TimeClassNames.*;

amishra-u and others added 15 commits October 4, 2024 10:40
…r.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…TimeFormatTemplates.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…TimeFormatTemplates.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…tionTemplates.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…TimeTemplates.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…odTemplate.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…ClassNames.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…ZoneTemplates.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…ZoneTemplates.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…rTest.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…rTest.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…rTest.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…rTest.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…rTest.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@sambsnyd sambsnyd merged commit 631f5dc into openrewrite:main Oct 4, 2024
0 of 2 checks passed
@timtebeek timtebeek added the recipe Recipe requested label Oct 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
recipe Recipe requested
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants