]> source.dussan.org Git - jgit.git/commitdiff
TestRepository: Add getInstant method 21/204821/1
authorDavid Ostrovsky <david@ostrovsky.org>
Thu, 5 Oct 2023 21:04:00 +0000 (23:04 +0200)
committerDavid Ostrovsky <david@ostrovsky.org>
Thu, 5 Oct 2023 21:09:33 +0000 (23:09 +0200)
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

org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java

index 671abaec958f3abf701db2c6bd4faeec00c74bb7..a2e0a571eb2450efe5eee6d05e1fb1f48c626db1 100644 (file)
@@ -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;
@@ -201,6 +202,16 @@ public class TestRepository<R extends Repository> implements AutoCloseable {
                return new Date(mockSystemReader.getCurrentTime());
        }
 
+       /**
+        * Get instant
+        *
+        * @return current instant.
+        * @since 6.8
+        */
+       public Instant getInstant() {
+               return Instant.ofEpochMilli(mockSystemReader.getCurrentTime());
+       }
+
        /**
         * Get timezone
         *