--- old/src/java.base/windows/classes/sun/nio/fs/WindowsFileAttributes.java 2019-09-20 15:04:02.000000000 -0700 +++ new/src/java.base/windows/classes/sun/nio/fs/WindowsFileAttributes.java 2019-09-20 15:04:01.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -108,8 +108,8 @@ private static final short OFFSETOF_FIND_DATA_SIZELOW = 32; private static final short OFFSETOF_FIND_DATA_RESERVED0 = 36; - // used to adjust values between Windows and java epoch - private static final long WINDOWS_EPOCH_IN_MICROSECONDS = -11644473600000000L; + // used to adjust values between Windows and java epochs + private static final long WINDOWS_EPOCH_IN_100NS = -116444736000000000L; // indicates if accurate metadata is required (interesting on NTFS only) private static final boolean ensureAccurateMetadata; @@ -137,23 +137,24 @@ * since January 1, 1601 to a FileTime. */ static FileTime toFileTime(long time) { - // 100ns -> us - time /= 10L; - // adjust to java epoch - time += WINDOWS_EPOCH_IN_MICROSECONDS; - return FileTime.from(time, TimeUnit.MICROSECONDS); + // adjust to java epoch retaining 100ns precision + time += WINDOWS_EPOCH_IN_100NS; + // 100ns -> ns + time *= 100L; + return FileTime.from(time, TimeUnit.NANOSECONDS); } /** - * Convert FileTime to 64-bit value representing the number of 100-nanosecond - * intervals since January 1, 1601. + * Convert FileTime to 64-bit value representing the number of + * 100-nanosecond intervals since January 1, 1601. */ static long toWindowsTime(FileTime time) { - long value = time.to(TimeUnit.MICROSECONDS); - // adjust to Windows epoch+= 11644473600000000L; - value -= WINDOWS_EPOCH_IN_MICROSECONDS; - // us -> 100ns - value *= 10L; + // FileTime -> ns + long value = time.to(TimeUnit.NANOSECONDS); + // ns -> 100ns + value /= 100L; + // adjust to Windows epoch += 116444736000000000L; + value -= WINDOWS_EPOCH_IN_100NS; return value; }