GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — chore: migrate org.joda.time to java.time (JSR310) (#8032) · nes-a-cti/java-docs-samples@42eb506

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • appengine-java11-bundled-services/datastore
    • pom.xml
  • appengine-java17-bundled-services/datastore
    • pom.xml
  • appengine-java8/datastore
    • pom.xml
    • src
      • main/java/com/example
        • appengine
          • AbstractGuestbook.java
          • Greeting.java
        • time
          • Clock.java
          • SystemClock.java
          • testing
            • FakeClock.java
      • test/java/com/example/appengine
        • GuestbookStrongTest.java
  • iot/api-client
    • codelab/manager
      • pom.xml
      • src/main/java/com/example/cloud/iot/examples
        • MqttCommandsDemo.java
    • end-to-end-example
      • pom.xml
      • src/main/java/com/example/cloud/iot/endtoend
        • CloudiotPubsubExampleMqttDevice.java
    • manager
      • pom.xml
      • src/main/java/com/example/cloud/iot/examples
        • HttpExample.java
        • MqttExample.java
  • trace
    • pom.xml
    • src/main/java/com/example/trace
      • TraceSample.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎appengine-java11-bundled-services/datastore/pom.xml‎

Copy file name to clipboardExpand all lines: appengine-java11-bundled-services/datastore/pom.xml
-6Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,6 @@
8888
<artifactId>guava</artifactId>
8989
</dependency>
9090

91-
<dependency>
92-
<groupId>joda-time</groupId>
93-
<artifactId>joda-time</artifactId>
94-
<version>2.12.2</version>
95-
</dependency>
96-
9791
<!-- Test Dependencies -->
9892
<dependency>
9993
<groupId>junit</groupId>
Collapse file

‎appengine-java17-bundled-services/datastore/pom.xml‎

Copy file name to clipboardExpand all lines: appengine-java17-bundled-services/datastore/pom.xml
-6Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,6 @@
8888
<artifactId>guava</artifactId>
8989
</dependency>
9090

91-
<dependency>
92-
<groupId>joda-time</groupId>
93-
<artifactId>joda-time</artifactId>
94-
<version>2.12.2</version>
95-
</dependency>
96-
9791
<!-- Test Dependencies -->
9892
<dependency>
9993
<groupId>junit</groupId>
Collapse file

‎appengine-java8/datastore/pom.xml‎

Copy file name to clipboardExpand all lines: appengine-java8/datastore/pom.xml
-6Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,6 @@
8686
<artifactId>guava</artifactId>
8787
</dependency>
8888

89-
<dependency>
90-
<groupId>joda-time</groupId>
91-
<artifactId>joda-time</artifactId>
92-
<version>2.12.2</version>
93-
</dependency>
94-
9589
<!-- Test Dependencies -->
9690
<dependency>
9791
<groupId>junit</groupId>
Collapse file

‎appengine-java8/datastore/src/main/java/com/example/appengine/AbstractGuestbook.java‎

Copy file name to clipboardExpand all lines: appengine-java8/datastore/src/main/java/com/example/appengine/AbstractGuestbook.java
+2-4Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,8 @@ abstract class AbstractGuestbook {
4848
* Appends a new greeting to the guestbook and returns the {@link Entity} that was created.
4949
**/
5050
public Greeting appendGreeting(String content) {
51-
Greeting greeting =
52-
Greeting.create(
53-
createGreeting(datastore, userService.getCurrentUser(), clock.now().toDate(), content));
54-
return greeting;
51+
return Greeting.create(
52+
createGreeting(datastore, userService.getCurrentUser(), Date.from(clock.now()), content));
5553
}
5654

5755
/**
Collapse file

‎appengine-java8/datastore/src/main/java/com/example/appengine/Greeting.java‎

Copy file name to clipboardExpand all lines: appengine-java8/datastore/src/main/java/com/example/appengine/Greeting.java
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@
1919
import com.google.appengine.api.datastore.Entity;
2020
import com.google.appengine.api.users.User;
2121
import com.google.auto.value.AutoValue;
22+
import java.time.Instant;
2223
import java.util.Date;
2324
import javax.annotation.Nullable;
24-
import org.joda.time.Instant;
2525

2626
@AutoValue
2727
public abstract class Greeting {
2828

2929
static Greeting create(Entity entity) {
3030
User user = (User) entity.getProperty("user");
31-
Instant date = new Instant((Date) entity.getProperty("date"));
31+
Instant date = ((Date) entity.getProperty("date")).toInstant();
3232
String content = (String) entity.getProperty("content");
3333
return new AutoValue_Greeting(user, date, content);
3434
}
Collapse file

‎appengine-java8/datastore/src/main/java/com/example/time/Clock.java‎

Copy file name to clipboardExpand all lines: appengine-java8/datastore/src/main/java/com/example/time/Clock.java
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616

1717
package com.example.time;
1818

19-
import org.joda.time.Instant;
19+
import java.time.Instant;
2020

2121
/**
2222
* Provides the current value of "now." To preserve testability, avoid all other libraries that
2323
* access the system clock (whether {@linkplain System#currentTimeMillis directly} or {@linkplain
24-
* org.joda.time.DateTime#DateTime() indirectly}).
24+
* java.time.Instant#now() indirectly}).
2525
*
2626
* <p>In production, use the {@link SystemClock} implementation to return the "real" system time. In
2727
* tests, either use {@link com.example.time.testing.FakeClock}, or get an instance from a mocking
Collapse file

‎appengine-java8/datastore/src/main/java/com/example/time/SystemClock.java‎

Copy file name to clipboardExpand all lines: appengine-java8/datastore/src/main/java/com/example/time/SystemClock.java
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package com.example.time;
1818

19-
import org.joda.time.Instant;
19+
import java.time.Instant;
2020

2121
/**
2222
* Clock implementation that returns the "real" system time.
@@ -34,6 +34,6 @@ public SystemClock() {
3434

3535
@Override
3636
public Instant now() {
37-
return new Instant();
37+
return Instant.now();
3838
}
3939
}
Collapse file

‎appengine-java8/datastore/src/main/java/com/example/time/testing/FakeClock.java‎

Copy file name to clipboardExpand all lines: appengine-java8/datastore/src/main/java/com/example/time/testing/FakeClock.java
+16-17Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@
1717
package com.example.time.testing;
1818

1919
import com.example.time.Clock;
20+
import java.time.Duration;
21+
import java.time.Instant;
2022
import java.util.concurrent.atomic.AtomicLong;
21-
import org.joda.time.Instant;
22-
import org.joda.time.ReadableDuration;
23-
import org.joda.time.ReadableInstant;
2423

2524
/**
2625
* A Clock that returns a fixed Instant value as the current clock time. The fixed Instant is
@@ -35,7 +34,7 @@
3534
*/
3635
public class FakeClock implements Clock {
3736

38-
private static final Instant DEFAULT_TIME = new Instant(1000000000L);
37+
private static final Instant DEFAULT_TIME = Instant.ofEpochMilli(1000000000L);
3938
private final long baseTimeMs;
4039
private final AtomicLong fakeNowMs;
4140
private volatile long autoIncrementStepMs;
@@ -50,8 +49,8 @@ public FakeClock() {
5049
/**
5150
* Creates a FakeClock instance initialized to the given time.
5251
*/
53-
public FakeClock(ReadableInstant now) {
54-
baseTimeMs = now.getMillis();
52+
public FakeClock(Instant now) {
53+
baseTimeMs = now.toEpochMilli();
5554
fakeNowMs = new AtomicLong(baseTimeMs);
5655
}
5756

@@ -60,8 +59,8 @@ public FakeClock(ReadableInstant now) {
6059
*
6160
* @return this
6261
*/
63-
public FakeClock setNow(ReadableInstant now) {
64-
fakeNowMs.set(now.getMillis());
62+
public FakeClock setNow(Instant now) {
63+
fakeNowMs.set(now.toEpochMilli());
6564
return this;
6665
}
6766

@@ -75,7 +74,7 @@ public Instant now() {
7574
* behavior of {@link #now()} is the same as this method.
7675
*/
7776
public Instant peek() {
78-
return new Instant(fakeNowMs.get());
77+
return Instant.ofEpochMilli(fakeNowMs.get());
7978
}
8079

8180
/**
@@ -95,8 +94,8 @@ public FakeClock resetTime() {
9594
* @param duration the duration to increment the clock time by
9695
* @return this
9796
*/
98-
public FakeClock incrementTime(ReadableDuration duration) {
99-
incrementTime(duration.getMillis());
97+
public FakeClock incrementTime(Duration duration) {
98+
incrementTime(duration.toMillis());
10099
return this;
101100
}
102101

@@ -117,8 +116,8 @@ public FakeClock incrementTime(long durationMs) {
117116
* @param duration the duration to decrement the clock time by
118117
* @return this
119118
*/
120-
public FakeClock decrementTime(ReadableDuration duration) {
121-
incrementTime(-duration.getMillis());
119+
public FakeClock decrementTime(Duration duration) {
120+
incrementTime(-duration.toMillis());
122121
return this;
123122
}
124123

@@ -140,8 +139,8 @@ public FakeClock decrementTime(long durationMs) {
140139
* @param autoIncrementStep the new auto increment duration
141140
* @return this
142141
*/
143-
public FakeClock setAutoIncrementStep(ReadableDuration autoIncrementStep) {
144-
setAutoIncrementStep(autoIncrementStep.getMillis());
142+
public FakeClock setAutoIncrementStep(Duration autoIncrementStep) {
143+
setAutoIncrementStep(autoIncrementStep.toMillis());
145144
return this;
146145
}
147146

@@ -165,7 +164,7 @@ public FakeClock setAutoIncrementStep(long autoIncrementStepMs) {
165164
* @see AtomicLong#addAndGet
166165
*/
167166
protected final Instant addAndGet(long durationMs) {
168-
return new Instant(fakeNowMs.addAndGet(durationMs));
167+
return Instant.ofEpochMilli(fakeNowMs.addAndGet(durationMs));
169168
}
170169

171170
/**
@@ -176,6 +175,6 @@ protected final Instant addAndGet(long durationMs) {
176175
* @see AtomicLong#getAndAdd
177176
*/
178177
protected final Instant getAndAdd(long durationMs) {
179-
return new Instant(fakeNowMs.getAndAdd(durationMs));
178+
return Instant.ofEpochMilli(fakeNowMs.getAndAdd(durationMs));
180179
}
181180
}
Collapse file

‎appengine-java8/datastore/src/test/java/com/example/appengine/GuestbookStrongTest.java‎

Copy file name to clipboardExpand all lines: appengine-java8/datastore/src/test/java/com/example/appengine/GuestbookStrongTest.java
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig;
2424
import com.google.appengine.tools.development.testing.LocalServiceTestHelper;
2525
import com.google.appengine.tools.development.testing.LocalUserServiceTestConfig;
26+
import java.time.Instant;
2627
import java.util.List;
27-
import org.joda.time.Instant;
2828
import org.junit.After;
2929
import org.junit.Before;
3030
import org.junit.Test;
@@ -37,7 +37,7 @@
3737
@RunWith(JUnit4.class)
3838
public class GuestbookStrongTest {
3939

40-
private static final Instant FAKE_NOW = new Instant(1234567890L);
40+
private static final Instant FAKE_NOW = Instant.ofEpochMilli(1234567890L);
4141
private static final String GUESTBOOK_ID = "my guestbook";
4242

4343
// Set maximum eventual consistency.
Collapse file

‎iot/api-client/codelab/manager/pom.xml‎

Copy file name to clipboardExpand all lines: iot/api-client/codelab/manager/pom.xml
-5Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,6 @@
7272
<artifactId>jjwt</artifactId>
7373
<version>0.9.1</version>
7474
</dependency>
75-
<dependency>
76-
<groupId>joda-time</groupId>
77-
<artifactId>joda-time</artifactId>
78-
<version>2.12.2</version>
79-
</dependency>
8075
<dependency>
8176
<groupId>com.google.apis</groupId>
8277
<artifactId>google-api-services-cloudiot</artifactId>

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.