Skip to content

Commit 44f0272

Browse files
committed
Minor polish
1 parent 6bfc13f commit 44f0272

File tree

2 files changed

+33
-30
lines changed

2 files changed

+33
-30
lines changed

src/main/resources/META-INF/rewrite/no-joda-time.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@
1616
---
1717
type: specs.openrewrite.org/v1beta/recipe
1818
name: org.openrewrite.java.migrate.joda.NoJodaTime
19-
displayName: Prefer the Java standard library instead of JodaTime
19+
displayName: Prefer the Java standard library instead of Joda-Time
2020
description: >-
21-
Before Java 8, Java lacked a robust date and time library, leading to the widespread use of Joda-Time to fill this
22-
gap. With the release of Java 8, the java.time package was introduced, incorporating most of Joda-Time's concepts.
23-
Features deemed too specialized or bulky for java.time were included in the ThreeTen-Extra library. This recipe
24-
migrates JodaTime types to java.time and threeten-extra types.
21+
Before Java 8, Java lacked a robust date and time library, leading to the widespread use of Joda-Time to fill this
22+
gap. With the release of Java 8, the `java.time` package was introduced, incorporating most of Joda-Time's concepts.
23+
Features deemed too specialized or bulky for `java.time` were included in the ThreeTen-Extra library. This recipe
24+
migrates Joda-Time types to `java.time` and `threeten-extra` types.
2525
tags:
2626
- joda-time
2727
recipeList:
28-
- org.openrewrite.java.migrate.joda.JodaTimeRecipe
2928
- org.openrewrite.java.dependencies.AddDependency:
3029
groupId: org.threeten
3130
artifactId: threeten-extra
3231
version: 1.8.0
33-
onlyIfUsing: org.joda.time.*Interval*
32+
onlyIfUsing: org.joda.time.*Interval*
33+
- org.openrewrite.java.migrate.joda.JodaTimeRecipe

src/test/java/org/openrewrite/java/migrate/joda/NoJodaTimeTest.java

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package org.openrewrite.java.migrate.joda;
1717

1818
import org.junit.jupiter.api.Test;
19+
import org.openrewrite.DocumentExample;
1920
import org.openrewrite.java.JavaParser;
2021
import org.openrewrite.test.RecipeSpec;
2122
import 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

Comments
 (0)