From 5138b97b604f0bb50940186ebb6c11b32ef9551b Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Thu, 5 Oct 2023 23:04:00 +0200 Subject: 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 --- .../src/org/eclipse/jgit/junit/TestRepository.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'org.eclipse.jgit.junit/src/org') 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; @@ -201,6 +202,16 @@ public class TestRepository 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 * -- cgit v1.2.3