1616package org .openrewrite .java .migrate .joda ;
1717
1818import org .junit .jupiter .api .Test ;
19+ import org .openrewrite .DocumentExample ;
1920import org .openrewrite .java .JavaParser ;
2021import org .openrewrite .test .RecipeSpec ;
2122import org .openrewrite .test .RewriteTest ;
@@ -31,6 +32,8 @@ public void defaults(RecipeSpec spec) {
3132 .recipeFromResource ("/META-INF/rewrite/no-joda-time.yml" , "org.openrewrite.java.migrate.joda.NoJodaTime" )
3233 .parser (JavaParser .fromJavaVersion ().classpath ("joda-time" , "threeten-extra" ));
3334 }
35+
36+ @ DocumentExample
3437 @ Test
3538 void migrateJodaTime () {
3639 rewriteRun (
@@ -39,32 +42,32 @@ void migrateJodaTime() {
3942 // language=java
4043 java (
4144 """
42- import org.joda.time.DateTime;
43- import org.joda.time.Interval;
44-
45- public class A {
46- public void foo() {
47- DateTime dt = new DateTime();
48- DateTime dt1 = new DateTime().plusDays(1);
49- Interval i = new Interval(dt, dt1);
50- System.out.println(i.toDuration());
51- }
52- }
53- """ ,
45+ import org.joda.time.DateTime;
46+ import org.joda.time.Interval;
47+
48+ class A {
49+ void foo() {
50+ DateTime dt = new DateTime();
51+ DateTime dt1 = new DateTime().plusDays(1);
52+ Interval i = new Interval(dt, dt1);
53+ System.out.println(i.toDuration());
54+ }
55+ }
56+ """ ,
5457 """
55- import org.threeten.extra.Interval;
58+ import org.threeten.extra.Interval;
5659
57- import java.time.ZonedDateTime;
60+ import java.time.ZonedDateTime;
5861
59- public class A {
60- public void foo() {
61- ZonedDateTime dt = ZonedDateTime.now();
62- ZonedDateTime dt1 = ZonedDateTime.now().plusDays(1);
63- Interval i = Interval.of(dt.toInstant(), dt1.toInstant());
64- System.out.println(i.toDuration());
65- }
66- }
67- """
62+ class A {
63+ void foo() {
64+ ZonedDateTime dt = ZonedDateTime.now();
65+ ZonedDateTime dt1 = ZonedDateTime.now().plusDays(1);
66+ Interval i = Interval.of(dt.toInstant(), dt1.toInstant());
67+ System.out.println(i.toDuration());
68+ }
69+ }
70+ """
6871 ),
6972 //language=xml
7073 pomXml (
0 commit comments