From 62e0c6af963d68607c8d7887f504404361b3a7e2 Mon Sep 17 00:00:00 2001 From: Kurt Alfred Kluever Date: Mon, 23 Oct 2023 11:01:11 -0700 Subject: [PATCH] Store an `Instant` in `FakeFileTimeSource` instead of a `FileTime`. RELNOTES=n/a PiperOrigin-RevId: 575869851 --- .../java/com/google/common/jimfs/FakeFileTimeSource.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/jimfs/src/test/java/com/google/common/jimfs/FakeFileTimeSource.java b/jimfs/src/test/java/com/google/common/jimfs/FakeFileTimeSource.java index 991cc206..8fcb64b2 100644 --- a/jimfs/src/test/java/com/google/common/jimfs/FakeFileTimeSource.java +++ b/jimfs/src/test/java/com/google/common/jimfs/FakeFileTimeSource.java @@ -26,7 +26,7 @@ final class FakeFileTimeSource implements FileTimeSource { private final Random random = new Random(System.currentTimeMillis()); - private FileTime now; + private Instant now; FakeFileTimeSource() { randomize(); @@ -34,25 +34,24 @@ final class FakeFileTimeSource implements FileTimeSource { @CanIgnoreReturnValue FakeFileTimeSource randomize() { - Instant randomNow = + now = Instant.ofEpochSecond( random .longs(Instant.MIN.getEpochSecond(), Instant.MAX.getEpochSecond()) .findAny() .getAsLong(), random.nextInt(1_000_000_000)); - this.now = FileTime.from(randomNow); return this; } @CanIgnoreReturnValue FakeFileTimeSource advance(Duration duration) { - this.now = FileTime.from(now.toInstant().plus(duration)); + this.now = now.plus(duration); return this; } @Override public FileTime now() { - return now; + return FileTime.from(now); } }