summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.junit
diff options
context:
space:
mode:
authorDavid Ostrovsky <david@ostrovsky.org>2023-10-05 23:04:00 +0200
committerDavid Ostrovsky <david@ostrovsky.org>2023-10-05 23:09:33 +0200
commit5138b97b604f0bb50940186ebb6c11b32ef9551b (patch)
tree4c668d805264c3c6cf60f70234b414f1a2ae0446 /org.eclipse.jgit.junit
parentf41ef035b607e1a81c15d9ee5477d52c3f96f03b (diff)
downloadjgit-5138b97b604f0bb50940186ebb6c11b32ef9551b.tar.gz
jgit-5138b97b604f0bb50940186ebb6c11b32ef9551b.zip
TestRepository: Add getInstant method
Error Prone is flagging Date-API as obsolete and recommends to migrate to Instant and LocalDate. Given that more JGit users starting to migrate to new Time API, offer getInstant method. Change-Id: Ie010b76d1c213cd0a645f716783ed2d57fc78071
Diffstat (limited to 'org.eclipse.jgit.junit')
-rw-r--r--org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
index 671abaec95..a2e0a571eb 100644
--- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
+++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
@@ -20,6 +20,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.security.MessageDigest;
+import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -202,6 +203,16 @@ public class TestRepository<R extends Repository> implements AutoCloseable {
}
/**
+ * Get instant
+ *
+ * @return current instant.
+ * @since 6.8
+ */
+ public Instant getInstant() {
+ return Instant.ofEpochMilli(mockSystemReader.getCurrentTime());
+ }
+
+ /**
* Get timezone
*
* @return timezone used for default identities.