Open source
Prefer the Java standard library instead of Joda-Time
Recipe ID
org.openrewrite.java.joda.time.NoJodaTimeArtifact
org.openrewrite.recipe:rewrite-jodaDefinition
Recipes67
67 recipes
- Add Gradle or Maven dependency
- Change method name
- Change method name
- Change method name
- Change method name
- Change method name
- Change method name
- Change method name
- Change method name
- Change method name
- Change method name
- Change method name
- Change method name
- Change method name
- Change method name
- Change method name
- Change method name
- Change method name
- Change method name
- Change method name
- Change method name
- Change method name
- Change method name
- Change method name
- Change method name
- Change method name
- Change method name
- Change method name
- Change method name
- Change method name
- Change method name
- Change method name
- Change method name
- Change method name
- Change method name
- Change method name
- Migrate Joda-Time
DateTimetojava.time.ZonedDateTime - Migrate Joda-Time
AbstractInstantto Java time - Migrate Joda-Time
Durationto Java time - Migrate Joda-Time
Intervalto Java time - Migrate Joda-Time
LocalDatetojava.time.LocalDate - Migrate Joda-Time
LocalTimetojava.time.LocalTime - Migrate Joda-Time formatter to Java time
- Migrate Joda-Time
DateTimeZoneto Java time - Migrate Joda-Time
DateMidnightto Java time - Migrate Joda-Time
Instantto Java time - Migrate Joda-Time
Days,Hours,Minutes,Secondsto Java time - Change type
- Change type
- Change type
- Change type
- Change type
- Change type
- Change type
- Change type
- Change type
- Change type
- Change type
- Change type
- Change type
- Change type
- Change type
- Change type
- Change type
- Change type
- Change type
- Change type
Examples
java
- java
- Diff
Before
import org.joda.time.DateTime;
import org.joda.time.Duration;
import org.joda.time.Instant;
import org.joda.time.format.DateTimeFormat;
class A {
public void foo() {
new DateTime().equals(DateTime.now());
new DateTime().getZone();
new DateTime().isAfter(1234567890L);
new Instant().isAfter(1234567890L);
new DateTime().isAfter(DateTime.now().minusDays(1));
new Instant().isAfter(Instant.now().minus(Duration.standardDays(1)));
new DateTime().isBefore(1234567890L);
new Instant().isBefore(1234567890L);
new DateTime().isBefore(DateTime.now().plusDays(1));
new Instant().isBefore(Instant.now().plus(Duration.standardDays(1)));
new DateTime().isBeforeNow();
new DateTime().isEqual(1234567890L);
new DateTime().isEqual(DateTime.now().plusDays(1));
new DateTime().toDate();
new DateTime().toInstant();
new DateTime().toString();
new DateTime().toString(DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss"));
}
}
After
import java.time.Duration;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
class A {
public void foo() {
ZonedDateTime.now().equals(ZonedDateTime.now());
ZonedDateTime.now().getZone();
ZonedDateTime.now().isAfter(Instant.ofEpochMilli(1234567890L).atZone(ZoneId.systemDefault()));
Instant.now().isAfter(Instant.ofEpochMilli(1234567890L));
ZonedDateTime.now().isAfter(ZonedDateTime.now().minusDays(1));
Instant.now().isAfter(Instant.now().minus(Duration.ofDays(1)));
ZonedDateTime.now().isBefore(Instant.ofEpochMilli(1234567890L).atZone(ZoneId.systemDefault()));
Instant.now().isBefore(Instant.ofEpochMilli(1234567890L));
ZonedDateTime.now().isBefore(ZonedDateTime.now().plusDays(1));
Instant.now().isBefore(Instant.now().plus(Duration.ofDays(1)));
ZonedDateTime.now().isBefore(ZonedDateTime.now());
ZonedDateTime.now().isEqual(Instant.ofEpochMilli(1234567890L).atZone(ZoneId.systemDefault()));
ZonedDateTime.now().isEqual(ZonedDateTime.now().plusDays(1));
Date.from(ZonedDateTime.now().toInstant());
ZonedDateTime.now().toInstant();
ZonedDateTime.now().toString();
ZonedDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"));
}
}
@@ -1,4 +1,6 @@
-import org.joda.time.DateTime;
-import org.joda.time.Duration;
-import org.joda.time.Instant;
-import org.joda.time.format.DateTimeFormat;
+import java.time.Duration;
+import java.time.Instant;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Date;
@@ -8,17 +10,17 @@
class A {
public void foo() {
- new DateTime().equals(DateTime.now());
- new DateTime().getZone();
- new DateTime().isAfter(1234567890L);
- new Instant().isAfter(1234567890L);
- new DateTime().isAfter(DateTime.now().minusDays(1));
- new Instant().isAfter(Instant.now().minus(Duration.standardDays(1)));
- new DateTime().isBefore(1234567890L);
- new Instant().isBefore(1234567890L);
- new DateTime().isBefore(DateTime.now().plusDays(1));
- new Instant().isBefore(Instant.now().plus(Duration.standardDays(1)));
- new DateTime().isBeforeNow();
- new DateTime().isEqual(1234567890L);
- new DateTime().isEqual(DateTime.now().plusDays(1));
- new DateTime().toDate();
- new DateTime().toInstant();
- new DateTime().toString();
- new DateTime().toString(DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss"));
+ ZonedDateTime.now().equals(ZonedDateTime.now());
+ ZonedDateTime.now().getZone();
+ ZonedDateTime.now().isAfter(Instant.ofEpochMilli(1234567890L).atZone(ZoneId.systemDefault()));
+ Instant.now().isAfter(Instant.ofEpochMilli(1234567890L));
+ ZonedDateTime.now().isAfter(ZonedDateTime.now().minusDays(1));
+ Instant.now().isAfter(Instant.now().minus(Duration.ofDays(1)));
+ ZonedDateTime.now().isBefore(Instant.ofEpochMilli(1234567890L).atZone(ZoneId.systemDefault()));
+ Instant.now().isBefore(Instant.ofEpochMilli(1234567890L));
+ ZonedDateTime.now().isBefore(ZonedDateTime.now().plusDays(1));
+ Instant.now().isBefore(Instant.now().plus(Duration.ofDays(1)));
+ ZonedDateTime.now().isBefore(ZonedDateTime.now());
+ ZonedDateTime.now().isEqual(Instant.ofEpochMilli(1234567890L).atZone(ZoneId.systemDefault()));
+ ZonedDateTime.now().isEqual(ZonedDateTime.now().plusDays(1));
+ Date.from(ZonedDateTime.now().toInstant());
+ ZonedDateTime.now().toInstant();
+ ZonedDateTime.now().toString();
+ ZonedDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"));
}
java
- java
- Diff
Before
import org.joda.time.DateMidnight;
class A {
public void foo() {
new DateMidnight();
}
}
After
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.ZoneOffset;
class A {
public void foo() {
LocalDate.now().atStartOfDay(ZoneOffset.of(ZoneId.systemDefault().getId()));
}
}
@@ -1,1 +1,3 @@
-import org.joda.time.DateMidnight;
+import java.time.LocalDate;
+import java.time.ZoneId;
+import java.time.ZoneOffset;
@@ -5,1 +7,1 @@
class A {
public void foo() {
- new DateMidnight();
+ LocalDate.now().atStartOfDay(ZoneOffset.of(ZoneId.systemDefault().getId()));
}
java
- java
- Diff
Before
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import java.util.TimeZone;
class A {
public void foo() {
new DateTime();
new DateTime(DateTimeZone.UTC);
new DateTime(1234567890L);
new DateTime(1234567890L, DateTimeZone.forID("America/New_York"));
new DateTime(2024, 9, 30, 12, 58);
new DateTime(2024, 9, 30, 12, 58, DateTimeZone.forOffsetHours(2));
new DateTime(2024, 9, 30, 13, 3, 15);
new DateTime(2024, 9, 30, 13, 3, 15, DateTimeZone.forOffsetHoursMinutes(5, 30));
new DateTime(2024, 9, 30, 13, 49, 15, 545);
new DateTime(2024, 9, 30, 13, 49, 15, 545, DateTimeZone.forTimeZone(TimeZone.getTimeZone("America/New_York")));
}
}
After
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.util.TimeZone;
class A {
public void foo() {
ZonedDateTime.now();
ZonedDateTime.now(ZoneOffset.UTC);
ZonedDateTime.ofInstant(Instant.ofEpochMilli(1234567890L), ZoneId.systemDefault());
ZonedDateTime.ofInstant(Instant.ofEpochMilli(1234567890L), ZoneId.of("America/New_York"));
ZonedDateTime.of(2024, 9, 30, 12, 58, 0, 0, ZoneId.systemDefault());
ZonedDateTime.of(2024, 9, 30, 12, 58, 0, 0, ZoneOffset.ofHours(2));
ZonedDateTime.of(2024, 9, 30, 13, 3, 15, 0, ZoneId.systemDefault());
ZonedDateTime.of(2024, 9, 30, 13, 3, 15, 0, ZoneOffset.ofHoursMinutes(5, 30));
ZonedDateTime.of(2024, 9, 30, 13, 49, 15, 545 * 1_000_000, ZoneId.systemDefault());
ZonedDateTime.of(2024, 9, 30, 13, 49, 15, 545 * 1_000_000, TimeZone.getTimeZone("America/New_York").toZoneId());
}
}
@@ -1,2 +1,4 @@
-import org.joda.time.DateTime;
-import org.joda.time.DateTimeZone;
+import java.time.Instant;
+import java.time.ZoneId;
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
import java.util.TimeZone;
@@ -7,10 +9,10 @@
class A {
public void foo() {
- new DateTime();
- new DateTime(DateTimeZone.UTC);
- new DateTime(1234567890L);
- new DateTime(1234567890L, DateTimeZone.forID("America/New_York"));
- new DateTime(2024, 9, 30, 12, 58);
- new DateTime(2024, 9, 30, 12, 58, DateTimeZone.forOffsetHours(2));
- new DateTime(2024, 9, 30, 13, 3, 15);
- new DateTime(2024, 9, 30, 13, 3, 15, DateTimeZone.forOffsetHoursMinutes(5, 30));
- new DateTime(2024, 9, 30, 13, 49, 15, 545);
- new DateTime(2024, 9, 30, 13, 49, 15, 545, DateTimeZone.forTimeZone(TimeZone.getTimeZone("America/New_York")));
+ ZonedDateTime.now();
+ ZonedDateTime.now(ZoneOffset.UTC);
+ ZonedDateTime.ofInstant(Instant.ofEpochMilli(1234567890L), ZoneId.systemDefault());
+ ZonedDateTime.ofInstant(Instant.ofEpochMilli(1234567890L), ZoneId.of("America/New_York"));
+ ZonedDateTime.of(2024, 9, 30, 12, 58, 0, 0, ZoneId.systemDefault());
+ ZonedDateTime.of(2024, 9, 30, 12, 58, 0, 0, ZoneOffset.ofHours(2));
+ ZonedDateTime.of(2024, 9, 30, 13, 3, 15, 0, ZoneId.systemDefault());
+ ZonedDateTime.of(2024, 9, 30, 13, 3, 15, 0, ZoneOffset.ofHoursMinutes(5, 30));
+ ZonedDateTime.of(2024, 9, 30, 13, 49, 15, 545 * 1_000_000, ZoneId.systemDefault());
+ ZonedDateTime.of(2024, 9, 30, 13, 49, 15, 545 * 1_000_000, TimeZone.getTimeZone("America/New_York").toZoneId());
}
java
- java
- Diff
Before
import org.joda.time.DateTimeZone;
import java.util.TimeZone;
class A {
public void foo() {
DateTimeZone.UTC.toString();
DateTimeZone.forID("America/New_York");
DateTimeZone.forOffsetHours(2);
DateTimeZone.forOffsetHoursMinutes(5, 30);
DateTimeZone.forTimeZone(TimeZone.getTimeZone("America/New_York"));
}
}
After
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.util.TimeZone;
class A {
public void foo() {
ZoneOffset.UTC.toString();
ZoneId.of("America/New_York");
ZoneOffset.ofHours(2);
ZoneOffset.ofHoursMinutes(5, 30);
TimeZone.getTimeZone("America/New_York").toZoneId();
}
}
@@ -1,1 +1,2 @@
-import org.joda.time.DateTimeZone;
+import java.time.ZoneId;
+import java.time.ZoneOffset;
import java.util.TimeZone;
@@ -6,5 +7,5 @@
class A {
public void foo() {
- DateTimeZone.UTC.toString();
- DateTimeZone.forID("America/New_York");
- DateTimeZone.forOffsetHours(2);
- DateTimeZone.forOffsetHoursMinutes(5, 30);
- DateTimeZone.forTimeZone(TimeZone.getTimeZone("America/New_York"));
+ ZoneOffset.UTC.toString();
+ ZoneId.of("America/New_York");
+ ZoneOffset.ofHours(2);
+ ZoneOffset.ofHoursMinutes(5, 30);
+ TimeZone.getTimeZone("America/New_York").toZoneId();
}
java
- java
- Diff
Before
import org.joda.time.Duration;
class A {
public void foo() {
Duration.standardDays(1L);
Duration.standardHours(1L);
Duration.standardMinutes(1L);
Duration.standardSeconds(1L);
Duration.millis(1000L);
new Duration(1000L);
new Duration(1000L, 2000L);
new Duration(1000L).getStandardDays();
new Duration(1000L).getStandardHours();
new Duration(1000L).getStandardMinutes();
new Duration(1000L).getStandardSeconds();
new Duration(1000L).toDuration();
new Duration(1000L).withMillis(2000L);
new Duration(1000L).withDurationAdded(550L, 2);
new Duration(1000L).withDurationAdded(new Duration(550L), 2);
new Duration(1000L).plus(550L);
new Duration(1000L).plus(new Duration(550L));
new Duration(1000L).minus(550L);
new Duration(1000L).minus(new Duration(550L));
new Duration(1000L).multipliedBy(2);
new Duration(1000L).dividedBy(2);
new Duration(1000L).negated();
new Duration(1000L).abs();
}
}
After
import java.time.Duration;
import java.time.Instant;
class A {
public void foo() {
Duration.ofDays(1L);
Duration.ofHours(1L);
Duration.ofMinutes(1L);
Duration.ofSeconds(1L);
Duration.ofMillis(1000L);
Duration.ofMillis(1000L);
Duration.between(Instant.ofEpochMilli(1000L), Instant.ofEpochMilli(2000L));
Duration.ofMillis(1000L).toDays();
Duration.ofMillis(1000L).toHours();
Duration.ofMillis(1000L).toMinutes();
Duration.ofMillis(1000L).getSeconds();
Duration.ofMillis(1000L);
Duration.ofMillis(2000L);
Duration.ofMillis(1000L).plusMillis(550L * 2);
Duration.ofMillis(1000L).plus(Duration.ofMillis(550L).multipliedBy(2));
Duration.ofMillis(1000L).plusMillis(550L);
Duration.ofMillis(1000L).plus(Duration.ofMillis(550L));
Duration.ofMillis(1000L).minusMillis(550L);
Duration.ofMillis(1000L).minus(Duration.ofMillis(550L));
Duration.ofMillis(1000L).multipliedBy(2);
Duration.ofMillis(1000L).dividedBy(2);
Duration.ofMillis(1000L).negated();
Duration.ofMillis(1000L).abs();
}
}
@@ -1,1 +1,2 @@
-import org.joda.time.Duration;
+import java.time.Duration;
+import java.time.Instant;
@@ -5,23 +6,23 @@
class A {
public void foo() {
- Duration.standardDays(1L);
- Duration.standardHours(1L);
- Duration.standardMinutes(1L);
- Duration.standardSeconds(1L);
- Duration.millis(1000L);
- new Duration(1000L);
- new Duration(1000L, 2000L);
- new Duration(1000L).getStandardDays();
- new Duration(1000L).getStandardHours();
- new Duration(1000L).getStandardMinutes();
- new Duration(1000L).getStandardSeconds();
- new Duration(1000L).toDuration();
- new Duration(1000L).withMillis(2000L);
- new Duration(1000L).withDurationAdded(550L, 2);
- new Duration(1000L).withDurationAdded(new Duration(550L), 2);
- new Duration(1000L).plus(550L);
- new Duration(1000L).plus(new Duration(550L));
- new Duration(1000L).minus(550L);
- new Duration(1000L).minus(new Duration(550L));
- new Duration(1000L).multipliedBy(2);
- new Duration(1000L).dividedBy(2);
- new Duration(1000L).negated();
- new Duration(1000L).abs();
+ Duration.ofDays(1L);
+ Duration.ofHours(1L);
+ Duration.ofMinutes(1L);
+ Duration.ofSeconds(1L);
+ Duration.ofMillis(1000L);
+ Duration.ofMillis(1000L);
+ Duration.between(Instant.ofEpochMilli(1000L), Instant.ofEpochMilli(2000L));
+ Duration.ofMillis(1000L).toDays();
+ Duration.ofMillis(1000L).toHours();
+ Duration.ofMillis(1000L).toMinutes();
+ Duration.ofMillis(1000L).getSeconds();
+ Duration.ofMillis(1000L);
+ Duration.ofMillis(2000L);
+ Duration.ofMillis(1000L).plusMillis(550L * 2);
+ Duration.ofMillis(1000L).plus(Duration.ofMillis(550L).multipliedBy(2));
+ Duration.ofMillis(1000L).plusMillis(550L);
+ Duration.ofMillis(1000L).plus(Duration.ofMillis(550L));
+ Duration.ofMillis(1000L).minusMillis(550L);
+ Duration.ofMillis(1000L).minus(Duration.ofMillis(550L));
+ Duration.ofMillis(1000L).multipliedBy(2);
+ Duration.ofMillis(1000L).dividedBy(2);
+ Duration.ofMillis(1000L).negated();
+ Duration.ofMillis(1000L).abs();
}
java
- java
- Diff
Before
import org.joda.time.format.DateTimeFormat;
class A {
public void foo() {
DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
DateTimeFormat.shortDate();
DateTimeFormat.mediumDate();
DateTimeFormat.longDate();
DateTimeFormat.fullDate();
DateTimeFormat.shortTime();
DateTimeFormat.mediumTime();
DateTimeFormat.longTime();
DateTimeFormat.fullTime();
DateTimeFormat.shortDateTime();
DateTimeFormat.mediumDateTime();
DateTimeFormat.longDateTime();
DateTimeFormat.fullDateTime();
}
}
After
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
class A {
public void foo() {
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT);
DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM);
DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG);
DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL);
DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT);
DateTimeFormatter.ofLocalizedTime(FormatStyle.MEDIUM);
DateTimeFormatter.ofLocalizedTime(FormatStyle.LONG);
DateTimeFormatter.ofLocalizedTime(FormatStyle.FULL);
DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT, FormatStyle.SHORT);
DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM, FormatStyle.MEDIUM);
DateTimeFormatter.ofLocalizedDateTime(FormatStyle.LONG, FormatStyle.LONG);
DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL, FormatStyle.FULL);
}
}
@@ -1,1 +1,2 @@
-import org.joda.time.format.DateTimeFormat;
+import java.time.format.DateTimeFormatter;
+import java.time.format.FormatStyle;
@@ -5,13 +6,13 @@
class A {
public void foo() {
- DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
- DateTimeFormat.shortDate();
- DateTimeFormat.mediumDate();
- DateTimeFormat.longDate();
- DateTimeFormat.fullDate();
- DateTimeFormat.shortTime();
- DateTimeFormat.mediumTime();
- DateTimeFormat.longTime();
- DateTimeFormat.fullTime();
- DateTimeFormat.shortDateTime();
- DateTimeFormat.mediumDateTime();
- DateTimeFormat.longDateTime();
- DateTimeFormat.fullDateTime();
+ DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
+ DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT);
+ DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM);
+ DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG);
+ DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL);
+ DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT);
+ DateTimeFormatter.ofLocalizedTime(FormatStyle.MEDIUM);
+ DateTimeFormatter.ofLocalizedTime(FormatStyle.LONG);
+ DateTimeFormatter.ofLocalizedTime(FormatStyle.FULL);
+ DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT, FormatStyle.SHORT);
+ DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM, FormatStyle.MEDIUM);
+ DateTimeFormatter.ofLocalizedDateTime(FormatStyle.LONG, FormatStyle.LONG);
+ DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL, FormatStyle.FULL);
}
java
- java
- Diff
Before
import org.joda.time.Instant;
import org.joda.time.Duration;
class A {
public void foo() {
new Instant();
Instant.now().getMillis();
Instant.now().minus(Duration.standardDays(1L));
Instant.ofEpochMilli(1234567890L);
Instant.parse("2024-10-25T15:45:00");
Instant.now().plus(Duration.standardDays(1L));
}
}
After
import java.time.Duration;
import java.time.Instant;
class A {
public void foo() {
Instant.now();
Instant.now().toEpochMilli();
Instant.now().minus(Duration.ofDays(1L));
Instant.ofEpochMilli(1234567890L);
Instant.parse("2024-10-25T15:45:00");
Instant.now().plus(Duration.ofDays(1L));
}
}
@@ -1,2 +1,2 @@
-import org.joda.time.Instant;
-import org.joda.time.Duration;
+import java.time.Duration;
+import java.time.Instant;
@@ -6,3 +6,3 @@
class A {
public void foo() {
- new Instant();
- Instant.now().getMillis();
- Instant.now().minus(Duration.standardDays(1L));
+ Instant.now();
+ Instant.now().toEpochMilli();
+ Instant.now().minus(Duration.ofDays(1L));
Instant.ofEpochMilli(1234567890L);
@@ -11,1 +11,1 @@
Instant.ofEpochMilli(1234567890L);
Instant.parse("2024-10-25T15:45:00");
- Instant.now().plus(Duration.standardDays(1L));
+ Instant.now().plus(Duration.ofDays(1L));
}
java
- java
- Diff
Before
import org.joda.time.DateTime;
import org.joda.time.Duration;
import org.joda.time.Interval;
import org.joda.time.DateTimeZone;
class A {
public void foo() {
new Interval(50, 100);
new Interval(50, 100, DateTimeZone.UTC);
new Interval(DateTime.now(), DateTime.now().plusDays(1));
new Interval(DateTime.now(), Duration.standardDays(1));
}
}
After
import org.threeten.extra.Interval;
import java.time.Duration;
import java.time.Instant;
import java.time.ZonedDateTime;
class A {
public void foo() {
Interval.of(Instant.ofEpochMilli(50), Instant.ofEpochMilli(100));
Interval.of(Instant.ofEpochMilli(50), Instant.ofEpochMilli(100));
Interval.of(ZonedDateTime.now().toInstant(), ZonedDateTime.now().plusDays(1).toInstant());
Interval.of(ZonedDateTime.now().toInstant(), Duration.ofDays(1));
}
}
@@ -1,4 +1,1 @@
-import org.joda.time.DateTime;
-import org.joda.time.Duration;
-import org.joda.time.Interval;
-import org.joda.time.DateTimeZone;
+import org.threeten.extra.Interval;
@@ -6,0 +3,4 @@
import org.joda.time.DateTimeZone;
+import java.time.Duration;
+import java.time.Instant;
+import java.time.ZonedDateTime;
+
class A {
@@ -8,4 +9,4 @@
class A {
public void foo() {
- new Interval(50, 100);
- new Interval(50, 100, DateTimeZone.UTC);
- new Interval(DateTime.now(), DateTime.now().plusDays(1));
- new Interval(DateTime.now(), Duration.standardDays(1));
+ Interval.of(Instant.ofEpochMilli(50), Instant.ofEpochMilli(100));
+ Interval.of(Instant.ofEpochMilli(50), Instant.ofEpochMilli(100));
+ Interval.of(ZonedDateTime.now().toInstant(), ZonedDateTime.now().plusDays(1).toInstant());
+ Interval.of(ZonedDateTime.now().toInstant(), Duration.ofDays(1));
}
java
- java
- Diff
Before
import org.joda.time.DateTimeZone;
import org.joda.time.LocalDate;
import org.joda.time.LocalTime;
class A {
public void foo() {
new LocalDate();
new LocalDate(DateTimeZone.UTC);
new LocalDate(2024, 10, 25);
new LocalDate(1234567890L);
new LocalDate(1234567890L, DateTimeZone.UTC);
LocalDate.now().getDayOfWeek();
LocalDate.now().getMonthOfYear();
LocalDate.now().withMonthOfYear(6);
LocalDate.now().plusDays(1);
LocalDate.now().toDateTimeAtStartOfDay();
LocalDate.now().toDateTimeAtStartOfDay(DateTimeZone.UTC);
LocalDate.now().toLocalDateTime(new LocalTime(10, 30));
}
}
After
import java.time.*;
class A {
public void foo() {
LocalDate.now();
LocalDate.now(ZoneOffset.UTC);
LocalDate.of(2024, 10, 25);
Instant.ofEpochMilli(1234567890L).atZone(ZoneId.systemDefault()).toLocalDate();
Instant.ofEpochMilli(1234567890L).atZone(ZoneOffset.UTC).toLocalDate();
LocalDate.now().getDayOfWeek().getValue();
LocalDate.now().getMonthValue();
LocalDate.now().withMonth(6);
LocalDate.now().plusDays(1);
LocalDate.now().atStartOfDay(ZoneId.systemDefault());
LocalDate.now().atStartOfDay(ZoneOffset.UTC);
LocalDate.now().atTime(LocalTime.of(10, 30));
}
}
@@ -1,3 +1,1 @@
-import org.joda.time.DateTimeZone;
-import org.joda.time.LocalDate;
-import org.joda.time.LocalTime;
+import java.time.*;
@@ -7,8 +5,8 @@
class A {
public void foo() {
- new LocalDate();
- new LocalDate(DateTimeZone.UTC);
- new LocalDate(2024, 10, 25);
- new LocalDate(1234567890L);
- new LocalDate(1234567890L, DateTimeZone.UTC);
- LocalDate.now().getDayOfWeek();
- LocalDate.now().getMonthOfYear();
- LocalDate.now().withMonthOfYear(6);
+ LocalDate.now();
+ LocalDate.now(ZoneOffset.UTC);
+ LocalDate.of(2024, 10, 25);
+ Instant.ofEpochMilli(1234567890L).atZone(ZoneId.systemDefault()).toLocalDate();
+ Instant.ofEpochMilli(1234567890L).atZone(ZoneOffset.UTC).toLocalDate();
+ LocalDate.now().getDayOfWeek().getValue();
+ LocalDate.now().getMonthValue();
+ LocalDate.now().withMonth(6);
LocalDate.now().plusDays(1);
@@ -16,3 +14,3 @@
LocalDate.now().withMonthOfYear(6);
LocalDate.now().plusDays(1);
- LocalDate.now().toDateTimeAtStartOfDay();
- LocalDate.now().toDateTimeAtStartOfDay(DateTimeZone.UTC);
- LocalDate.now().toLocalDateTime(new LocalTime(10, 30));
+ LocalDate.now().atStartOfDay(ZoneId.systemDefault());
+ LocalDate.now().atStartOfDay(ZoneOffset.UTC);
+ LocalDate.now().atTime(LocalTime.of(10, 30));
}
java
- java
- Diff
Before
import org.joda.time.DateTimeZone;
import org.joda.time.LocalTime;
class A {
public void foo() {
new LocalTime();
new LocalTime(DateTimeZone.UTC);
new LocalTime(10, 30);
new LocalTime(10, 30, 45);
new LocalTime(10, 30, 45, 500);
LocalTime.now().plusMillis(100);
LocalTime.now().minusMillis(100);
LocalTime.now().withMillisOfSecond(500);
LocalTime.now().getMillisOfSecond();
LocalTime.now().getMillisOfDay();
LocalTime.now().getHourOfDay();
LocalTime.now().getMinuteOfHour();
LocalTime.now().getSecondOfMinute();
LocalTime.now().withHourOfDay(10);
LocalTime.now().withMinuteOfHour(30);
LocalTime.now().withSecondOfMinute(45);
LocalTime.now().toDateTimeToday();
LocalTime.now().toDateTimeToday(DateTimeZone.UTC);
}
}
After
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.temporal.ChronoField;
class A {
public void foo() {
LocalTime.now();
LocalTime.now(ZoneOffset.UTC);
LocalTime.of(10, 30);
LocalTime.of(10, 30, 45);
LocalTime.of(10, 30, 45, 500 * 1_000_000);
LocalTime.now().plusNanos(100 * 1_000_000L);
LocalTime.now().minusNanos(100 * 1_000_000L);
LocalTime.now().withNano(500 * 1_000_000);
LocalTime.now().get(ChronoField.MILLI_OF_SECOND);
LocalTime.now().get(ChronoField.MILLI_OF_DAY);
LocalTime.now().getHour();
LocalTime.now().getMinute();
LocalTime.now().getSecond();
LocalTime.now().withHour(10);
LocalTime.now().withMinute(30);
LocalTime.now().withSecond(45);
LocalTime.now().atDate(LocalDate.now()).atZone(ZoneId.systemDefault());
LocalTime.now().atDate(LocalDate.now(ZoneOffset.UTC)).atZone(ZoneOffset.UTC);
}
}
@@ -1,2 +1,5 @@
-import org.joda.time.DateTimeZone;
-import org.joda.time.LocalTime;
+import java.time.LocalDate;
+import java.time.LocalTime;
+import java.time.ZoneId;
+import java.time.ZoneOffset;
+import java.time.temporal.ChronoField;
@@ -6,18 +9,18 @@
class A {
public void foo() {
- new LocalTime();
- new LocalTime(DateTimeZone.UTC);
- new LocalTime(10, 30);
- new LocalTime(10, 30, 45);
- new LocalTime(10, 30, 45, 500);
- LocalTime.now().plusMillis(100);
- LocalTime.now().minusMillis(100);
- LocalTime.now().withMillisOfSecond(500);
- LocalTime.now().getMillisOfSecond();
- LocalTime.now().getMillisOfDay();
- LocalTime.now().getHourOfDay();
- LocalTime.now().getMinuteOfHour();
- LocalTime.now().getSecondOfMinute();
- LocalTime.now().withHourOfDay(10);
- LocalTime.now().withMinuteOfHour(30);
- LocalTime.now().withSecondOfMinute(45);
- LocalTime.now().toDateTimeToday();
- LocalTime.now().toDateTimeToday(DateTimeZone.UTC);
+ LocalTime.now();
+ LocalTime.now(ZoneOffset.UTC);
+ LocalTime.of(10, 30);
+ LocalTime.of(10, 30, 45);
+ LocalTime.of(10, 30, 45, 500 * 1_000_000);
+ LocalTime.now().plusNanos(100 * 1_000_000L);
+ LocalTime.now().minusNanos(100 * 1_000_000L);
+ LocalTime.now().withNano(500 * 1_000_000);
+ LocalTime.now().get(ChronoField.MILLI_OF_SECOND);
+ LocalTime.now().get(ChronoField.MILLI_OF_DAY);
+ LocalTime.now().getHour();
+ LocalTime.now().getMinute();
+ LocalTime.now().getSecond();
+ LocalTime.now().withHour(10);
+ LocalTime.now().withMinute(30);
+ LocalTime.now().withSecond(45);
+ LocalTime.now().atDate(LocalDate.now()).atZone(ZoneId.systemDefault());
+ LocalTime.now().atDate(LocalDate.now(ZoneOffset.UTC)).atZone(ZoneOffset.UTC);
}
java
- java
- Diff
Before
import org.joda.time.DateTime;
import org.joda.time.Days;
class A {
void foo(DateTime start, DateTime end) {
int days = Days.daysBetween(start, end).getDays();
}
}
After
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
class A {
void foo(ZonedDateTime start, ZonedDateTime end) {
int days = (int) ChronoUnit.DAYS.between(start, end);
}
}
@@ -1,2 +1,2 @@
-import org.joda.time.DateTime;
-import org.joda.time.Days;
+import java.time.ZonedDateTime;
+import java.time.temporal.ChronoUnit;
@@ -5,2 +5,2 @@
class A {
- void foo(DateTime start, DateTime end) {
- int days = Days.daysBetween(start, end).getDays();
+ void foo(ZonedDateTime start, ZonedDateTime end) {
+ int days = (int) ChronoUnit.DAYS.between(start, end);
}
java
- java
- Diff
Before
import org.joda.time.DateTime;
class A {
public void foo() {
DateTime dt = new DateTime();
dt.toDateTime().toString();
}
}
After
import java.time.ZonedDateTime;
class A {
public void foo() {
ZonedDateTime dt = ZonedDateTime.now();
dt.toString();
}
}
@@ -1,1 +1,1 @@
-import org.joda.time.DateTime;
+import java.time.ZonedDateTime;
@@ -5,2 +5,2 @@
class A {
public void foo() {
- DateTime dt = new DateTime();
- dt.toDateTime().toString();
+ ZonedDateTime dt = ZonedDateTime.now();
+ dt.toString();
}
java, xml
Unchanged
foo
- java
- Diff
Before
import org.joda.time.DateTime;
import org.joda.time.Interval;
class A {
void foo() {
DateTime dt = new DateTime();
DateTime dt1 = new DateTime().plusDays(1);
Interval i = new Interval(dt, dt1);
i.toDuration();
}
}
After
import org.threeten.extra.Interval;
import java.time.ZonedDateTime;
class A {
void foo() {
ZonedDateTime dt = ZonedDateTime.now();
ZonedDateTime dt1 = ZonedDateTime.now().plusDays(1);
Interval i = Interval.of(dt.toInstant(), dt1.toInstant());
i.toDuration();
}
}
@@ -1,2 +1,1 @@
-import org.joda.time.DateTime;
-import org.joda.time.Interval;
+import org.threeten.extra.Interval;
@@ -4,0 +3,2 @@
import org.joda.time.Interval;
+import java.time.ZonedDateTime;
+
class A {
@@ -6,3 +7,3 @@
class A {
void foo() {
- DateTime dt = new DateTime();
- DateTime dt1 = new DateTime().plusDays(1);
- Interval i = new Interval(dt, dt1);
+ ZonedDateTime dt = ZonedDateTime.now();
+ ZonedDateTime dt1 = ZonedDateTime.now().plusDays(1);
+ Interval i = Interval.of(dt.toInstant(), dt1.toInstant());
i.toDuration();
- xml
- Diff
Before
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.foobar</groupId>
<artifactId>foobar-core</artifactId>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.12.3</version>
</dependency>
</dependencies>
</project>
After
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.foobar</groupId>
<artifactId>foobar-core</artifactId>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.12.3</version>
</dependency>
<dependency>
<groupId>org.threeten</groupId>
<artifactId>threeten-extra</artifactId>
<version>1.8.0</version>
</dependency>
</dependencies>
</project>
--- pom.xml
+++ pom.xml
@@ -12,0 +12,5 @@
<version>2.12.3</version>
</dependency>
+ <dependency>
+ <groupId>org.threeten</groupId>
+ <artifactId>threeten-extra</artifactId>
+ <version>1.8.0</version>
+ </dependency>
</dependencies>
java
- java
- Diff
Before
import org.joda.time.DateTime;
import org.joda.time.Duration;
import org.joda.time.Instant;
import org.joda.time.format.DateTimeFormat;
class A {
public void foo() {
new DateTime().equals(DateTime.now());
new DateTime().getZone();
new DateTime().isAfter(1234567890L);
new Instant().isAfter(1234567890L);
new DateTime().isAfter(DateTime.now().minusDays(1));
new Instant().isAfter(Instant.now().minus(Duration.standardDays(1)));
new DateTime().isBefore(1234567890L);
new Instant().isBefore(1234567890L);
new DateTime().isBefore(DateTime.now().plusDays(1));
new Instant().isBefore(Instant.now().plus(Duration.standardDays(1)));
new DateTime().isBeforeNow();
new DateTime().isEqual(1234567890L);
new DateTime().isEqual(DateTime.now().plusDays(1));
new DateTime().toDate();
new DateTime().toInstant();
new DateTime().toString();
new DateTime().toString(DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss"));
}
}
After
import java.time.Duration;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
class A {
public void foo() {
ZonedDateTime.now().equals(ZonedDateTime.now());
ZonedDateTime.now().getZone();
ZonedDateTime.now().isAfter(Instant.ofEpochMilli(1234567890L).atZone(ZoneId.systemDefault()));
Instant.now().isAfter(Instant.ofEpochMilli(1234567890L));
ZonedDateTime.now().isAfter(ZonedDateTime.now().minusDays(1));
Instant.now().isAfter(Instant.now().minus(Duration.ofDays(1)));
ZonedDateTime.now().isBefore(Instant.ofEpochMilli(1234567890L).atZone(ZoneId.systemDefault()));
Instant.now().isBefore(Instant.ofEpochMilli(1234567890L));
ZonedDateTime.now().isBefore(ZonedDateTime.now().plusDays(1));
Instant.now().isBefore(Instant.now().plus(Duration.ofDays(1)));
ZonedDateTime.now().isBefore(ZonedDateTime.now());
ZonedDateTime.now().isEqual(Instant.ofEpochMilli(1234567890L).atZone(ZoneId.systemDefault()));
ZonedDateTime.now().isEqual(ZonedDateTime.now().plusDays(1));
Date.from(ZonedDateTime.now().toInstant());
ZonedDateTime.now().toInstant();
ZonedDateTime.now().toString();
ZonedDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"));
}
}
@@ -1,4 +1,6 @@
-import org.joda.time.DateTime;
-import org.joda.time.Duration;
-import org.joda.time.Instant;
-import org.joda.time.format.DateTimeFormat;
+import java.time.Duration;
+import java.time.Instant;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Date;
@@ -8,17 +10,17 @@
class A {
public void foo() {
- new DateTime().equals(DateTime.now());
- new DateTime().getZone();
- new DateTime().isAfter(1234567890L);
- new Instant().isAfter(1234567890L);
- new DateTime().isAfter(DateTime.now().minusDays(1));
- new Instant().isAfter(Instant.now().minus(Duration.standardDays(1)));
- new DateTime().isBefore(1234567890L);
- new Instant().isBefore(1234567890L);
- new DateTime().isBefore(DateTime.now().plusDays(1));
- new Instant().isBefore(Instant.now().plus(Duration.standardDays(1)));
- new DateTime().isBeforeNow();
- new DateTime().isEqual(1234567890L);
- new DateTime().isEqual(DateTime.now().plusDays(1));
- new DateTime().toDate();
- new DateTime().toInstant();
- new DateTime().toString();
- new DateTime().toString(DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss"));
+ ZonedDateTime.now().equals(ZonedDateTime.now());
+ ZonedDateTime.now().getZone();
+ ZonedDateTime.now().isAfter(Instant.ofEpochMilli(1234567890L).atZone(ZoneId.systemDefault()));
+ Instant.now().isAfter(Instant.ofEpochMilli(1234567890L));
+ ZonedDateTime.now().isAfter(ZonedDateTime.now().minusDays(1));
+ Instant.now().isAfter(Instant.now().minus(Duration.ofDays(1)));
+ ZonedDateTime.now().isBefore(Instant.ofEpochMilli(1234567890L).atZone(ZoneId.systemDefault()));
+ Instant.now().isBefore(Instant.ofEpochMilli(1234567890L));
+ ZonedDateTime.now().isBefore(ZonedDateTime.now().plusDays(1));
+ Instant.now().isBefore(Instant.now().plus(Duration.ofDays(1)));
+ ZonedDateTime.now().isBefore(ZonedDateTime.now());
+ ZonedDateTime.now().isEqual(Instant.ofEpochMilli(1234567890L).atZone(ZoneId.systemDefault()));
+ ZonedDateTime.now().isEqual(ZonedDateTime.now().plusDays(1));
+ Date.from(ZonedDateTime.now().toInstant());
+ ZonedDateTime.now().toInstant();
+ ZonedDateTime.now().toString();
+ ZonedDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"));
}
java
- java
- Diff
Before
import org.joda.time.DateMidnight;
class A {
public void foo() {
new DateMidnight();
}
}
After
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.ZoneOffset;
class A {
public void foo() {
LocalDate.now().atStartOfDay(ZoneOffset.of(ZoneId.systemDefault().getId()));
}
}
@@ -1,1 +1,3 @@
-import org.joda.time.DateMidnight;
+import java.time.LocalDate;
+import java.time.ZoneId;
+import java.time.ZoneOffset;
@@ -5,1 +7,1 @@
class A {
public void foo() {
- new DateMidnight();
+ LocalDate.now().atStartOfDay(ZoneOffset.of(ZoneId.systemDefault().getId()));
}
java
- java
- Diff
Before
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import java.util.TimeZone;
class A {
public void foo() {
new DateTime();
new DateTime(DateTimeZone.UTC);
new DateTime(1234567890L);
new DateTime(1234567890L, DateTimeZone.forID("America/New_York"));
new DateTime(2024, 9, 30, 12, 58);
new DateTime(2024, 9, 30, 12, 58, DateTimeZone.forOffsetHours(2));
new DateTime(2024, 9, 30, 13, 3, 15);
new DateTime(2024, 9, 30, 13, 3, 15, DateTimeZone.forOffsetHoursMinutes(5, 30));
new DateTime(2024, 9, 30, 13, 49, 15, 545);
new DateTime(2024, 9, 30, 13, 49, 15, 545, DateTimeZone.forTimeZone(TimeZone.getTimeZone("America/New_York")));
}
}
After
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.util.TimeZone;
class A {
public void foo() {
ZonedDateTime.now();
ZonedDateTime.now(ZoneOffset.UTC);
ZonedDateTime.ofInstant(Instant.ofEpochMilli(1234567890L), ZoneId.systemDefault());
ZonedDateTime.ofInstant(Instant.ofEpochMilli(1234567890L), ZoneId.of("America/New_York"));
ZonedDateTime.of(2024, 9, 30, 12, 58, 0, 0, ZoneId.systemDefault());
ZonedDateTime.of(2024, 9, 30, 12, 58, 0, 0, ZoneOffset.ofHours(2));
ZonedDateTime.of(2024, 9, 30, 13, 3, 15, 0, ZoneId.systemDefault());
ZonedDateTime.of(2024, 9, 30, 13, 3, 15, 0, ZoneOffset.ofHoursMinutes(5, 30));
ZonedDateTime.of(2024, 9, 30, 13, 49, 15, 545 * 1_000_000, ZoneId.systemDefault());
ZonedDateTime.of(2024, 9, 30, 13, 49, 15, 545 * 1_000_000, TimeZone.getTimeZone("America/New_York").toZoneId());
}
}
@@ -1,2 +1,4 @@
-import org.joda.time.DateTime;
-import org.joda.time.DateTimeZone;
+import java.time.Instant;
+import java.time.ZoneId;
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
import java.util.TimeZone;
@@ -7,10 +9,10 @@
class A {
public void foo() {
- new DateTime();
- new DateTime(DateTimeZone.UTC);
- new DateTime(1234567890L);
- new DateTime(1234567890L, DateTimeZone.forID("America/New_York"));
- new DateTime(2024, 9, 30, 12, 58);
- new DateTime(2024, 9, 30, 12, 58, DateTimeZone.forOffsetHours(2));
- new DateTime(2024, 9, 30, 13, 3, 15);
- new DateTime(2024, 9, 30, 13, 3, 15, DateTimeZone.forOffsetHoursMinutes(5, 30));
- new DateTime(2024, 9, 30, 13, 49, 15, 545);
- new DateTime(2024, 9, 30, 13, 49, 15, 545, DateTimeZone.forTimeZone(TimeZone.getTimeZone("America/New_York")));
+ ZonedDateTime.now();
+ ZonedDateTime.now(ZoneOffset.UTC);
+ ZonedDateTime.ofInstant(Instant.ofEpochMilli(1234567890L), ZoneId.systemDefault());
+ ZonedDateTime.ofInstant(Instant.ofEpochMilli(1234567890L), ZoneId.of("America/New_York"));
+ ZonedDateTime.of(2024, 9, 30, 12, 58, 0, 0, ZoneId.systemDefault());
+ ZonedDateTime.of(2024, 9, 30, 12, 58, 0, 0, ZoneOffset.ofHours(2));
+ ZonedDateTime.of(2024, 9, 30, 13, 3, 15, 0, ZoneId.systemDefault());
+ ZonedDateTime.of(2024, 9, 30, 13, 3, 15, 0, ZoneOffset.ofHoursMinutes(5, 30));
+ ZonedDateTime.of(2024, 9, 30, 13, 49, 15, 545 * 1_000_000, ZoneId.systemDefault());
+ ZonedDateTime.of(2024, 9, 30, 13, 49, 15, 545 * 1_000_000, TimeZone.getTimeZone("America/New_York").toZoneId());
}
java
- java
- Diff
Before
import org.joda.time.DateTimeZone;
import java.util.TimeZone;
class A {
public void foo() {
DateTimeZone.UTC.toString();
DateTimeZone.forID("America/New_York");
DateTimeZone.forOffsetHours(2);
DateTimeZone.forOffsetHoursMinutes(5, 30);
DateTimeZone.forTimeZone(TimeZone.getTimeZone("America/New_York"));
}
}
After
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.util.TimeZone;
class A {
public void foo() {
ZoneOffset.UTC.toString();
ZoneId.of("America/New_York");
ZoneOffset.ofHours(2);
ZoneOffset.ofHoursMinutes(5, 30);
TimeZone.getTimeZone("America/New_York").toZoneId();
}
}
@@ -1,1 +1,2 @@
-import org.joda.time.DateTimeZone;
+import java.time.ZoneId;
+import java.time.ZoneOffset;
import java.util.TimeZone;
@@ -6,5 +7,5 @@
class A {
public void foo() {
- DateTimeZone.UTC.toString();
- DateTimeZone.forID("America/New_York");
- DateTimeZone.forOffsetHours(2);
- DateTimeZone.forOffsetHoursMinutes(5, 30);
- DateTimeZone.forTimeZone(TimeZone.getTimeZone("America/New_York"));
+ ZoneOffset.UTC.toString();
+ ZoneId.of("America/New_York");
+ ZoneOffset.ofHours(2);
+ ZoneOffset.ofHoursMinutes(5, 30);
+ TimeZone.getTimeZone("America/New_York").toZoneId();
}
java
- java
- Diff
Before
import org.joda.time.Duration;
class A {
public void foo() {
Duration.standardDays(1L);
Duration.standardHours(1L);
Duration.standardMinutes(1L);
Duration.standardSeconds(1L);
Duration.millis(1000L);
new Duration(1000L);
new Duration(1000L, 2000L);
new Duration(1000L).getStandardDays();
new Duration(1000L).getStandardHours();
new Duration(1000L).getStandardMinutes();
new Duration(1000L).getStandardSeconds();
new Duration(1000L).toDuration();
new Duration(1000L).withMillis(2000L);
new Duration(1000L).withDurationAdded(550L, 2);
new Duration(1000L).withDurationAdded(new Duration(550L), 2);
new Duration(1000L).plus(550L);
new Duration(1000L).plus(new Duration(550L));
new Duration(1000L).minus(550L);
new Duration(1000L).minus(new Duration(550L));
new Duration(1000L).multipliedBy(2);
new Duration(1000L).dividedBy(2);
new Duration(1000L).negated();
new Duration(1000L).abs();
}
}
After
import java.time.Duration;
import java.time.Instant;
class A {
public void foo() {
Duration.ofDays(1L);
Duration.ofHours(1L);
Duration.ofMinutes(1L);
Duration.ofSeconds(1L);
Duration.ofMillis(1000L);
Duration.ofMillis(1000L);
Duration.between(Instant.ofEpochMilli(1000L), Instant.ofEpochMilli(2000L));
Duration.ofMillis(1000L).toDays();
Duration.ofMillis(1000L).toHours();
Duration.ofMillis(1000L).toMinutes();
Duration.ofMillis(1000L).getSeconds();
Duration.ofMillis(1000L);
Duration.ofMillis(2000L);
Duration.ofMillis(1000L).plusMillis(550L * 2);
Duration.ofMillis(1000L).plus(Duration.ofMillis(550L).multipliedBy(2));
Duration.ofMillis(1000L).plusMillis(550L);
Duration.ofMillis(1000L).plus(Duration.ofMillis(550L));
Duration.ofMillis(1000L).minusMillis(550L);
Duration.ofMillis(1000L).minus(Duration.ofMillis(550L));
Duration.ofMillis(1000L).multipliedBy(2);
Duration.ofMillis(1000L).dividedBy(2);
Duration.ofMillis(1000L).negated();
Duration.ofMillis(1000L).abs();
}
}
@@ -1,1 +1,2 @@
-import org.joda.time.Duration;
+import java.time.Duration;
+import java.time.Instant;
@@ -5,23 +6,23 @@
class A {
public void foo() {
- Duration.standardDays(1L);
- Duration.standardHours(1L);
- Duration.standardMinutes(1L);
- Duration.standardSeconds(1L);
- Duration.millis(1000L);
- new Duration(1000L);
- new Duration(1000L, 2000L);
- new Duration(1000L).getStandardDays();
- new Duration(1000L).getStandardHours();
- new Duration(1000L).getStandardMinutes();
- new Duration(1000L).getStandardSeconds();
- new Duration(1000L).toDuration();
- new Duration(1000L).withMillis(2000L);
- new Duration(1000L).withDurationAdded(550L, 2);
- new Duration(1000L).withDurationAdded(new Duration(550L), 2);
- new Duration(1000L).plus(550L);
- new Duration(1000L).plus(new Duration(550L));
- new Duration(1000L).minus(550L);
- new Duration(1000L).minus(new Duration(550L));
- new Duration(1000L).multipliedBy(2);
- new Duration(1000L).dividedBy(2);
- new Duration(1000L).negated();
- new Duration(1000L).abs();
+ Duration.ofDays(1L);
+ Duration.ofHours(1L);
+ Duration.ofMinutes(1L);
+ Duration.ofSeconds(1L);
+ Duration.ofMillis(1000L);
+ Duration.ofMillis(1000L);
+ Duration.between(Instant.ofEpochMilli(1000L), Instant.ofEpochMilli(2000L));
+ Duration.ofMillis(1000L).toDays();
+ Duration.ofMillis(1000L).toHours();
+ Duration.ofMillis(1000L).toMinutes();
+ Duration.ofMillis(1000L).getSeconds();
+ Duration.ofMillis(1000L);
+ Duration.ofMillis(2000L);
+ Duration.ofMillis(1000L).plusMillis(550L * 2);
+ Duration.ofMillis(1000L).plus(Duration.ofMillis(550L).multipliedBy(2));
+ Duration.ofMillis(1000L).plusMillis(550L);
+ Duration.ofMillis(1000L).plus(Duration.ofMillis(550L));
+ Duration.ofMillis(1000L).minusMillis(550L);
+ Duration.ofMillis(1000L).minus(Duration.ofMillis(550L));
+ Duration.ofMillis(1000L).multipliedBy(2);
+ Duration.ofMillis(1000L).dividedBy(2);
+ Duration.ofMillis(1000L).negated();
+ Duration.ofMillis(1000L).abs();
}
java
- java
- Diff
Before
import org.joda.time.format.DateTimeFormat;
class A {
public void foo() {
DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
DateTimeFormat.shortDate();
DateTimeFormat.mediumDate();
DateTimeFormat.longDate();
DateTimeFormat.fullDate();
DateTimeFormat.shortTime();
DateTimeFormat.mediumTime();
DateTimeFormat.longTime();
DateTimeFormat.fullTime();
DateTimeFormat.shortDateTime();
DateTimeFormat.mediumDateTime();
DateTimeFormat.longDateTime();
DateTimeFormat.fullDateTime();
}
}
After
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
class A {
public void foo() {
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT);
DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM);
DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG);
DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL);
DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT);
DateTimeFormatter.ofLocalizedTime(FormatStyle.MEDIUM);
DateTimeFormatter.ofLocalizedTime(FormatStyle.LONG);
DateTimeFormatter.ofLocalizedTime(FormatStyle.FULL);
DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT, FormatStyle.SHORT);
DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM, FormatStyle.MEDIUM);
DateTimeFormatter.ofLocalizedDateTime(FormatStyle.LONG, FormatStyle.LONG);
DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL, FormatStyle.FULL);
}
}
@@ -1,1 +1,2 @@
-import org.joda.time.format.DateTimeFormat;
+import java.time.format.DateTimeFormatter;
+import java.time.format.FormatStyle;
@@ -5,13 +6,13 @@
class A {
public void foo() {
- DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
- DateTimeFormat.shortDate();
- DateTimeFormat.mediumDate();
- DateTimeFormat.longDate();
- DateTimeFormat.fullDate();
- DateTimeFormat.shortTime();
- DateTimeFormat.mediumTime();
- DateTimeFormat.longTime();
- DateTimeFormat.fullTime();
- DateTimeFormat.shortDateTime();
- DateTimeFormat.mediumDateTime();
- DateTimeFormat.longDateTime();
- DateTimeFormat.fullDateTime();
+ DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
+ DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT);
+ DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM);
+ DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG);
+ DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL);
+ DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT);
+ DateTimeFormatter.ofLocalizedTime(FormatStyle.MEDIUM);
+ DateTimeFormatter.ofLocalizedTime(FormatStyle.LONG);
+ DateTimeFormatter.ofLocalizedTime(FormatStyle.FULL);
+ DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT, FormatStyle.SHORT);
+ DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM, FormatStyle.MEDIUM);
+ DateTimeFormatter.ofLocalizedDateTime(FormatStyle.LONG, FormatStyle.LONG);
+ DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL, FormatStyle.FULL);
}
java
- java
- Diff
Before
import org.joda.time.Instant;
import org.joda.time.Duration;
class A {
public void foo() {
new Instant();
Instant.now().getMillis();
Instant.now().minus(Duration.standardDays(1L));
Instant.ofEpochMilli(1234567890L);
Instant.parse("2024-10-25T15:45:00");
Instant.now().plus(Duration.standardDays(1L));
}
}
After
import java.time.Duration;
import java.time.Instant;
class A {
public void foo() {
Instant.now();
Instant.now().toEpochMilli();
Instant.now().minus(Duration.ofDays(1L));
Instant.ofEpochMilli(1234567890L);
Instant.parse("2024-10-25T15:45:00");
Instant.now().plus(Duration.ofDays(1L));
}
}
@@ -1,2 +1,2 @@
-import org.joda.time.Instant;
-import org.joda.time.Duration;
+import java.time.Duration;
+import java.time.Instant;
@@ -6,3 +6,3 @@
class A {
public void foo() {
- new Instant();
- Instant.now().getMillis();
- Instant.now().minus(Duration.standardDays(1L));
+ Instant.now();
+ Instant.now().toEpochMilli();
+ Instant.now().minus(Duration.ofDays(1L));
Instant.ofEpochMilli(1234567890L);
@@ -11,1 +11,1 @@
Instant.ofEpochMilli(1234567890L);
Instant.parse("2024-10-25T15:45:00");
- Instant.now().plus(Duration.standardDays(1L));
+ Instant.now().plus(Duration.ofDays(1L));
}
java
- java
- Diff
Before
import org.joda.time.DateTime;
import org.joda.time.Duration;
import org.joda.time.Interval;
import org.joda.time.DateTimeZone;
class A {
public void foo() {
new Interval(50, 100);
new Interval(50, 100, DateTimeZone.UTC);
new Interval(DateTime.now(), DateTime.now().plusDays(1));
new Interval(DateTime.now(), Duration.standardDays(1));
}
}
After
import org.threeten.extra.Interval;
import java.time.Duration;
import java.time.Instant;
import java.time.ZonedDateTime;
class A {
public void foo() {
Interval.of(Instant.ofEpochMilli(50), Instant.ofEpochMilli(100));
Interval.of(Instant.ofEpochMilli(50), Instant.ofEpochMilli(100));
Interval.of(ZonedDateTime.now().toInstant(), ZonedDateTime.now().plusDays(1).toInstant());
Interval.of(ZonedDateTime.now().toInstant(), Duration.ofDays(1));
}
}
@@ -1,4 +1,1 @@
-import org.joda.time.DateTime;
-import org.joda.time.Duration;
-import org.joda.time.Interval;
-import org.joda.time.DateTimeZone;
+import org.threeten.extra.Interval;
@@ -6,0 +3,4 @@
import org.joda.time.DateTimeZone;
+import java.time.Duration;
+import java.time.Instant;
+import java.time.ZonedDateTime;
+
class A {
@@ -8,4 +9,4 @@
class A {
public void foo() {
- new Interval(50, 100);
- new Interval(50, 100, DateTimeZone.UTC);
- new Interval(DateTime.now(), DateTime.now().plusDays(1));
- new Interval(DateTime.now(), Duration.standardDays(1));
+ Interval.of(Instant.ofEpochMilli(50), Instant.ofEpochMilli(100));
+ Interval.of(Instant.ofEpochMilli(50), Instant.ofEpochMilli(100));
+ Interval.of(ZonedDateTime.now().toInstant(), ZonedDateTime.now().plusDays(1).toInstant());
+ Interval.of(ZonedDateTime.now().toInstant(), Duration.ofDays(1));
}
java
- java
- Diff
Before
import org.joda.time.DateTimeZone;
import org.joda.time.LocalDate;
import org.joda.time.LocalTime;
class A {
public void foo() {
new LocalDate();
new LocalDate(DateTimeZone.UTC);
new LocalDate(2024, 10, 25);
new LocalDate(1234567890L);
new LocalDate(1234567890L, DateTimeZone.UTC);
LocalDate.now().getDayOfWeek();
LocalDate.now().getMonthOfYear();
LocalDate.now().withMonthOfYear(6);
LocalDate.now().plusDays(1);
LocalDate.now().toDateTimeAtStartOfDay();
LocalDate.now().toDateTimeAtStartOfDay(DateTimeZone.UTC);
LocalDate.now().toLocalDateTime(new LocalTime(10, 30));
}
}
After
import java.time.*;
class A {
public void foo() {
LocalDate.now();
LocalDate.now(ZoneOffset.UTC);
LocalDate.of(2024, 10, 25);
Instant.ofEpochMilli(1234567890L).atZone(ZoneId.systemDefault()).toLocalDate();
Instant.ofEpochMilli(1234567890L).atZone(ZoneOffset.UTC).toLocalDate();
LocalDate.now().getDayOfWeek().getValue();
LocalDate.now().getMonthValue();
LocalDate.now().withMonth(6);
LocalDate.now().plusDays(1);
LocalDate.now().atStartOfDay(ZoneId.systemDefault());
LocalDate.now().atStartOfDay(ZoneOffset.UTC);
LocalDate.now().atTime(LocalTime.of(10, 30));
}
}
@@ -1,3 +1,1 @@
-import org.joda.time.DateTimeZone;
-import org.joda.time.LocalDate;
-import org.joda.time.LocalTime;
+import java.time.*;
@@ -7,8 +5,8 @@
class A {
public void foo() {
- new LocalDate();
- new LocalDate(DateTimeZone.UTC);
- new LocalDate(2024, 10, 25);
- new LocalDate(1234567890L);
- new LocalDate(1234567890L, DateTimeZone.UTC);
- LocalDate.now().getDayOfWeek();
- LocalDate.now().getMonthOfYear();
- LocalDate.now().withMonthOfYear(6);
+ LocalDate.now();
+ LocalDate.now(ZoneOffset.UTC);
+ LocalDate.of(2024, 10, 25);
+ Instant.ofEpochMilli(1234567890L).atZone(ZoneId.systemDefault()).toLocalDate();
+ Instant.ofEpochMilli(1234567890L).atZone(ZoneOffset.UTC).toLocalDate();
+ LocalDate.now().getDayOfWeek().getValue();
+ LocalDate.now().getMonthValue();
+ LocalDate.now().withMonth(6);
LocalDate.now().plusDays(1);
@@ -16,3 +14,3 @@
LocalDate.now().withMonthOfYear(6);
LocalDate.now().plusDays(1);
- LocalDate.now().toDateTimeAtStartOfDay();
- LocalDate.now().toDateTimeAtStartOfDay(DateTimeZone.UTC);
- LocalDate.now().toLocalDateTime(new LocalTime(10, 30));
+ LocalDate.now().atStartOfDay(ZoneId.systemDefault());
+ LocalDate.now().atStartOfDay(ZoneOffset.UTC);
+ LocalDate.now().atTime(LocalTime.of(10, 30));
}
java
- java
- Diff
Before
import org.joda.time.DateTimeZone;
import org.joda.time.LocalTime;
class A {
public void foo() {
new LocalTime();
new LocalTime(DateTimeZone.UTC);
new LocalTime(10, 30);
new LocalTime(10, 30, 45);
new LocalTime(10, 30, 45, 500);
LocalTime.now().plusMillis(100);
LocalTime.now().minusMillis(100);
LocalTime.now().withMillisOfSecond(500);
LocalTime.now().getMillisOfSecond();
LocalTime.now().getMillisOfDay();
LocalTime.now().getHourOfDay();
LocalTime.now().getMinuteOfHour();
LocalTime.now().getSecondOfMinute();
LocalTime.now().withHourOfDay(10);
LocalTime.now().withMinuteOfHour(30);
LocalTime.now().withSecondOfMinute(45);
LocalTime.now().toDateTimeToday();
LocalTime.now().toDateTimeToday(DateTimeZone.UTC);
}
}
After
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.temporal.ChronoField;
class A {
public void foo() {
LocalTime.now();
LocalTime.now(ZoneOffset.UTC);
LocalTime.of(10, 30);
LocalTime.of(10, 30, 45);
LocalTime.of(10, 30, 45, 500 * 1_000_000);
LocalTime.now().plusNanos(100 * 1_000_000L);
LocalTime.now().minusNanos(100 * 1_000_000L);
LocalTime.now().withNano(500 * 1_000_000);
LocalTime.now().get(ChronoField.MILLI_OF_SECOND);
LocalTime.now().get(ChronoField.MILLI_OF_DAY);
LocalTime.now().getHour();
LocalTime.now().getMinute();
LocalTime.now().getSecond();
LocalTime.now().withHour(10);
LocalTime.now().withMinute(30);
LocalTime.now().withSecond(45);
LocalTime.now().atDate(LocalDate.now()).atZone(ZoneId.systemDefault());
LocalTime.now().atDate(LocalDate.now(ZoneOffset.UTC)).atZone(ZoneOffset.UTC);
}
}
@@ -1,2 +1,5 @@
-import org.joda.time.DateTimeZone;
-import org.joda.time.LocalTime;
+import java.time.LocalDate;
+import java.time.LocalTime;
+import java.time.ZoneId;
+import java.time.ZoneOffset;
+import java.time.temporal.ChronoField;
@@ -6,18 +9,18 @@
class A {
public void foo() {
- new LocalTime();
- new LocalTime(DateTimeZone.UTC);
- new LocalTime(10, 30);
- new LocalTime(10, 30, 45);
- new LocalTime(10, 30, 45, 500);
- LocalTime.now().plusMillis(100);
- LocalTime.now().minusMillis(100);
- LocalTime.now().withMillisOfSecond(500);
- LocalTime.now().getMillisOfSecond();
- LocalTime.now().getMillisOfDay();
- LocalTime.now().getHourOfDay();
- LocalTime.now().getMinuteOfHour();
- LocalTime.now().getSecondOfMinute();
- LocalTime.now().withHourOfDay(10);
- LocalTime.now().withMinuteOfHour(30);
- LocalTime.now().withSecondOfMinute(45);
- LocalTime.now().toDateTimeToday();
- LocalTime.now().toDateTimeToday(DateTimeZone.UTC);
+ LocalTime.now();
+ LocalTime.now(ZoneOffset.UTC);
+ LocalTime.of(10, 30);
+ LocalTime.of(10, 30, 45);
+ LocalTime.of(10, 30, 45, 500 * 1_000_000);
+ LocalTime.now().plusNanos(100 * 1_000_000L);
+ LocalTime.now().minusNanos(100 * 1_000_000L);
+ LocalTime.now().withNano(500 * 1_000_000);
+ LocalTime.now().get(ChronoField.MILLI_OF_SECOND);
+ LocalTime.now().get(ChronoField.MILLI_OF_DAY);
+ LocalTime.now().getHour();
+ LocalTime.now().getMinute();
+ LocalTime.now().getSecond();
+ LocalTime.now().withHour(10);
+ LocalTime.now().withMinute(30);
+ LocalTime.now().withSecond(45);
+ LocalTime.now().atDate(LocalDate.now()).atZone(ZoneId.systemDefault());
+ LocalTime.now().atDate(LocalDate.now(ZoneOffset.UTC)).atZone(ZoneOffset.UTC);
}
java
- java
- Diff
Before
import org.joda.time.DateTime;
import org.joda.time.Days;
class A {
void foo(DateTime start, DateTime end) {
int days = Days.daysBetween(start, end).getDays();
}
}
After
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
class A {
void foo(ZonedDateTime start, ZonedDateTime end) {
int days = (int) ChronoUnit.DAYS.between(start, end);
}
}
@@ -1,2 +1,2 @@
-import org.joda.time.DateTime;
-import org.joda.time.Days;
+import java.time.ZonedDateTime;
+import java.time.temporal.ChronoUnit;
@@ -5,2 +5,2 @@
class A {
- void foo(DateTime start, DateTime end) {
- int days = Days.daysBetween(start, end).getDays();
+ void foo(ZonedDateTime start, ZonedDateTime end) {
+ int days = (int) ChronoUnit.DAYS.between(start, end);
}
java
- java
- Diff
Before
import org.joda.time.DateTime;
class A {
public void foo() {
DateTime dt = new DateTime();
dt.toDateTime().toString();
}
}
After
import java.time.ZonedDateTime;
class A {
public void foo() {
ZonedDateTime dt = ZonedDateTime.now();
dt.toString();
}
}
@@ -1,1 +1,1 @@
-import org.joda.time.DateTime;
+import java.time.ZonedDateTime;
@@ -5,2 +5,2 @@
class A {
public void foo() {
- DateTime dt = new DateTime();
- dt.toDateTime().toString();
+ ZonedDateTime dt = ZonedDateTime.now();
+ dt.toString();
}
java, xml
Unchanged
foo
- java
- Diff
Before
import org.joda.time.DateTime;
import org.joda.time.Interval;
class A {
void foo() {
DateTime dt = new DateTime();
DateTime dt1 = new DateTime().plusDays(1);
Interval i = new Interval(dt, dt1);
i.toDuration();
}
}
After
import org.threeten.extra.Interval;
import java.time.ZonedDateTime;
class A {
void foo() {
ZonedDateTime dt = ZonedDateTime.now();
ZonedDateTime dt1 = ZonedDateTime.now().plusDays(1);
Interval i = Interval.of(dt.toInstant(), dt1.toInstant());
i.toDuration();
}
}
@@ -1,2 +1,1 @@
-import org.joda.time.DateTime;
-import org.joda.time.Interval;
+import org.threeten.extra.Interval;
@@ -4,0 +3,2 @@
import org.joda.time.Interval;
+import java.time.ZonedDateTime;
+
class A {
@@ -6,3 +7,3 @@
class A {
void foo() {
- DateTime dt = new DateTime();
- DateTime dt1 = new DateTime().plusDays(1);
- Interval i = new Interval(dt, dt1);
+ ZonedDateTime dt = ZonedDateTime.now();
+ ZonedDateTime dt1 = ZonedDateTime.now().plusDays(1);
+ Interval i = Interval.of(dt.toInstant(), dt1.toInstant());
i.toDuration();
- xml
- Diff
Before
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.foobar</groupId>
<artifactId>foobar-core</artifactId>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.12.3</version>
</dependency>
</dependencies>
</project>
After
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.foobar</groupId>
<artifactId>foobar-core</artifactId>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.12.3</version>
</dependency>
<dependency>
<groupId>org.threeten</groupId>
<artifactId>threeten-extra</artifactId>
<version>1.8.0</version>
</dependency>
</dependencies>
</project>
--- pom.xml
+++ pom.xml
@@ -12,0 +12,5 @@
<version>2.12.3</version>
</dependency>
+ <dependency>
+ <groupId>org.threeten</groupId>
+ <artifactId>threeten-extra</artifactId>
+ <version>1.8.0</version>
+ </dependency>
</dependencies>
Usage
Run this recipe
This recipe has no required configuration options. Users of Moderne can run it via the Moderne CLI.
You will need to have configured the Moderne CLI on your machine before you can run the following command.
shell
mod run . --recipe NoJodaTime
If the recipe is not available locally, then you can install it using:
mod config recipes jar install org.openrewrite.recipe:rewrite-joda:0.9.1
Data tables
Source files that had results
org.openrewrite.table.SourcesFileResultsSource files that were modified by the recipe run.
| Column | Description |
|---|---|
| Source path before the run | The source path of the file before the run. null when a source file was created during the run. |
| Source path after the run | A recipe may modify the source path. This is the path after the run. null when a source file was deleted during the run. |
| Parent of the recipe that made changes | In a hierarchical recipe, the parent of the recipe that made a change. Empty if this is the root of a hierarchy or if the recipe is not hierarchical at all. |
| Recipe that made changes | The specific recipe that made a change. |
| Estimated time saving | An estimated effort that a developer to fix manually instead of using this recipe, in unit of seconds. |
| Cycle | The recipe cycle in which the change was made. |
Source files that had search results
org.openrewrite.table.SearchResultsSearch results that were found during the recipe run.
| Column | Description |
|---|---|
| Source path of search result before the run | The source path of the file with the search result markers present. |
| Source path of search result after run the run | A recipe may modify the source path. This is the path after the run. null when a source file was deleted during the run. |
| Result | The trimmed printed tree of the LST element that the marker is attached to. |
| Description | The content of the description of the marker. |
| Recipe that added the search marker | The specific recipe that added the Search marker. |
Source files that errored on a recipe
org.openrewrite.table.SourcesFileErrorsThe details of all errors produced by a recipe run.
| Column | Description |
|---|---|
| Source path | The file that failed to parse. |
| Recipe that made changes | The specific recipe that made a change. |
| Stack trace | The stack trace of the failure. |
Recipe performance
org.openrewrite.table.RecipeRunStatsStatistics used in analyzing the performance of recipes.
| Column | Description |
|---|---|
| The recipe | The recipe whose stats are being measured both individually and cumulatively. |
| Source file count | The number of source files the recipe ran over. |
| Source file changed count | The number of source files which were changed in the recipe run. Includes files created, deleted, and edited. |
| Cumulative scanning time (ns) | The total time spent across the scanning phase of this recipe. |
| Max scanning time (ns) | The max time scanning any one source file. |
| Cumulative edit time (ns) | The total time spent across the editing phase of this recipe. |
| Max edit time (ns) | The max time editing any one source file. |