Class TimeUtils
java.lang.Object
org.apache.commons.compress.utils.TimeUtils
Utility class for handling time-related types and conversions.
Understanding UNIX vs NTFS timestamps:
- A UNIX timestamp is a primitive long starting at the UNIX Epoch on January 1st, 1970 at Coordinated Universal Time (UTC)
- An NTFS timestamp is a file time is a 64-bit value that represents the number of 100-nanosecond intervals that have elapsed since 12:00 A.M. January 1, 1601 Coordinated Universal Time (UTC).
- Since:
- 1.23
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
isUnixTime
(long seconds) Deprecated.static boolean
isUnixTime
(FileTime time) Deprecated.static Date
ntfsTimeToDate
(long ntfsTime) Deprecated.static FileTime
ntfsTimeToFileTime
(long ntfsTime) Deprecated.static Date
Deprecated.static FileTime
toFileTime
(Date date) Deprecated.static long
toNtfsTime
(long javaTime) Deprecated.static long
toNtfsTime
(FileTime fileTime) Deprecated.static long
toNtfsTime
(Date date) Deprecated.static long
toUnixTime
(FileTime fileTime) ConvertsFileTime
to standard UNIX time.static FileTime
truncateToHundredNanos
(FileTime fileTime) Truncates a FileTime to 100-nanosecond precision.static FileTime
unixTimeToFileTime
(long time) Deprecated.
-
Method Details
-
isUnixTime
Deprecated.Tests whether a FileTime can be safely represented in the standard UNIX time.TODO ? If the FileTime is null, this method always returns true.
- Parameters:
time
- the FileTime to evaluate, can be null.- Returns:
- true if the time exceeds the minimum or maximum UNIX time, false otherwise.
-
isUnixTime
Deprecated.Tests whether a given number of seconds (since Epoch) can be safely represented in the standard UNIX time.- Parameters:
seconds
- the number of seconds (since Epoch) to evaluate.- Returns:
- true if the time can be represented in the standard UNIX time, false otherwise.
-
ntfsTimeToDate
Deprecated.Converts NTFS time (100 nanosecond units since 1 January 1601) to Java time.- Parameters:
ntfsTime
- the NTFS time in 100 nanosecond units.- Returns:
- the Date.
-
ntfsTimeToFileTime
Deprecated.Converts NTFS time (100-nanosecond units since 1 January 1601) to a FileTime.- Parameters:
ntfsTime
- the NTFS time in 100-nanosecond units.- Returns:
- the FileTime.
- See Also:
-
toDate
Deprecated.- Parameters:
fileTime
- the file time to be converted.- Returns:
- a
Date
which corresponds to the supplied time, ornull
if the time isnull
. - See Also:
-
toFileTime
Deprecated.- Parameters:
date
- the date to be converted.- Returns:
- a
FileTime
which corresponds to the supplied date, ornull
if the date isnull
. - See Also:
-
toNtfsTime
Deprecated.Converts aDate
to NTFS time.- Parameters:
date
- the Date.- Returns:
- the NTFS time.
-
toNtfsTime
Deprecated.Converts aFileTime
to NTFS time (100-nanosecond units since 1 January 1601).- Parameters:
fileTime
- the FileTime.- Returns:
- the NTFS time in 100-nanosecond units.
- See Also:
-
toNtfsTime
Deprecated.Converts Java time (milliseconds since Epoch) to NTFS time.- Parameters:
javaTime
- the Java time.- Returns:
- the NTFS time.
-
toUnixTime
ConvertsFileTime
to standard UNIX time.- Parameters:
fileTime
- the original FileTime.- Returns:
- the UNIX timestamp.
-
truncateToHundredNanos
Truncates a FileTime to 100-nanosecond precision.- Parameters:
fileTime
- the FileTime to be truncated.- Returns:
- the truncated FileTime.
-
unixTimeToFileTime
Deprecated.Converts standard UNIX time (in seconds, UTC/GMT) toFileTime
.- Parameters:
time
- UNIX timestamp (in seconds, UTC/GMT).- Returns:
- the corresponding FileTime.
-
FileTimes.isUnixTime(long)