Skip to content

Commit

Permalink
Increase precision of SystemFileTimeSource.
Browse files Browse the repository at this point in the history
Fixes #277

RELNOTES=n/a
PiperOrigin-RevId: 575831203
  • Loading branch information
kluever authored and Jimfs Team committed Oct 23, 2023
1 parent 34d6b18 commit bdcd240
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bdcd240

Please sign in to comment.