From bdcd240a9ad7876105d0cbbce3b7a99487721b46 Mon Sep 17 00:00:00 2001 From: Kurt Alfred Kluever Date: Mon, 23 Oct 2023 08:49:35 -0700 Subject: [PATCH] Increase precision of `SystemFileTimeSource`. Fixes https://github.com/google/jimfs/issues/277 RELNOTES=n/a PiperOrigin-RevId: 575831203 --- .../java/com/google/common/jimfs/SystemFileTimeSource.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/jimfs/src/main/java/com/google/common/jimfs/SystemFileTimeSource.java b/jimfs/src/main/java/com/google/common/jimfs/SystemFileTimeSource.java index 47635b81..05d71f08 100644 --- a/jimfs/src/main/java/com/google/common/jimfs/SystemFileTimeSource.java +++ b/jimfs/src/main/java/com/google/common/jimfs/SystemFileTimeSource.java @@ -17,18 +17,15 @@ package com.google.common.jimfs; import java.nio.file.attribute.FileTime; +import java.time.Instant; /** Implementation of of {@link FileTimeSource} that gets the current time from the system. */ enum SystemFileTimeSource implements FileTimeSource { INSTANCE; - // If/when Jimfs requires Java 8 this should use the FileTime factory that takes an Instant as - // that has the potential to be more precise. At that point, we should make a similar change to - // FakeFileTimeSource. - @Override public FileTime now() { - return FileTime.fromMillis(System.currentTimeMillis()); + return FileTime.from(Instant.now()); } @Override