public final class TimeUtils extends Object
Understanding Unix vs NTFS timestamps:
Modifier and Type | Method and Description |
---|---|
static boolean |
isUnixTime(FileTime time)
Tests whether a FileTime can be safely represented in the standard UNIX time.
|
static boolean |
isUnixTime(long seconds)
Tests whether a given number of seconds (since Epoch) can be safely represented in the standard UNIX time.
|
static Date |
ntfsTimeToDate(long ntfsTime)
Converts NTFS time (100 nanosecond units since 1 January 1601) to Java time.
|
static FileTime |
ntfsTimeToFileTime(long ntfsTime)
Converts NTFS time (100-nanosecond units since 1 January 1601) to a FileTime.
|
static Date |
toDate(FileTime fileTime)
|
static FileTime |
toFileTime(Date date)
|
static long |
toNtfsTime(Date date)
Converts a
Date to NTFS time. |
static long |
toNtfsTime(FileTime fileTime)
Converts a
FileTime to NTFS time (100-nanosecond units since 1 January 1601). |
static long |
toNtfsTime(long javaTime)
Converts Java time (milliseconds since Epoch) to NTFS time.
|
static long |
toUnixTime(FileTime fileTime)
Converts
FileTime to standard UNIX time. |
static FileTime |
truncateToHundredNanos(FileTime fileTime)
Truncates a FileTime to 100-nanosecond precision.
|
static FileTime |
unixTimeToFileTime(long time)
Converts standard UNIX time (in seconds, UTC/GMT) to
FileTime . |
public static boolean isUnixTime(FileTime time)
TODO ? If the FileTime is null, this method always returns true.
time
- the FileTime to evaluate, can be nullpublic static boolean isUnixTime(long seconds)
seconds
- the number of seconds (since Epoch) to evaluatepublic static Date ntfsTimeToDate(long ntfsTime)
ntfsTime
- the NTFS time in 100 nanosecond unitspublic static FileTime ntfsTimeToFileTime(long ntfsTime)
ntfsTime
- the NTFS time in 100-nanosecond unitsWINDOWS_EPOCH_OFFSET
,
toNtfsTime(FileTime)
public static Date toDate(FileTime fileTime)
fileTime
- the file time to be converted.Date
which corresponds to the supplied time, or null
if the time is null
.toFileTime(Date)
public static FileTime toFileTime(Date date)
date
- the date to be converted.FileTime
which corresponds to the supplied date, or null
if the date is null
.toDate(FileTime)
public static long toNtfsTime(Date date)
Date
to NTFS time.date
- the Datepublic static long toNtfsTime(FileTime fileTime)
FileTime
to NTFS time (100-nanosecond units since 1 January 1601).fileTime
- the FileTimeWINDOWS_EPOCH_OFFSET
,
ntfsTimeToFileTime(long)
public static long toNtfsTime(long javaTime)
javaTime
- the Java timepublic static long toUnixTime(FileTime fileTime)
FileTime
to standard UNIX time.fileTime
- the original FileTimepublic static FileTime truncateToHundredNanos(FileTime fileTime)
fileTime
- the FileTime to be truncatedpublic static FileTime unixTimeToFileTime(long time)
FileTime
.time
- UNIX timestampCopyright © 2002–2022 The Apache Software Foundation. All rights reserved.