Package org.apache.commons.compress.utils

# Class TimeUtils

java.lang.Object
org.apache.commons.compress.utils.TimeUtils

@Deprecated public final class TimeUtils extends Object
Deprecated.
Use `FileTimes`.
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
See Also:
  - `FileTimes`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static boolean`
  `isUnixTime(long seconds)`
  Deprecated.
  Use `FileTimes.isUnixTime(long)`
  `static boolean`
  `isUnixTime(FileTime time)`
  Deprecated.
  use `FileTimes.isUnixTime(FileTime)`
  `static Date`
  `ntfsTimeToDate(long ntfsTime)`
  Deprecated.
  Use `FileTimes.ntfsTimeToDate(long)`.
  `static FileTime`
  `ntfsTimeToFileTime(long ntfsTime)`
  Deprecated.
  Use `FileTimes.ntfsTimeToFileTime(long)`.
  `static Date`
  `toDate(FileTime fileTime)`
  Deprecated.
  Use `FileTimes.toDate(FileTime)`.
  `static FileTime`
  `toFileTime(Date date)`
  Deprecated.
  Use `FileTimes.toFileTime(Date)`.
  `static long`
  `toNtfsTime(long javaTime)`
  Deprecated.
  Use `FileTimes.toNtfsTime(long)`
  `static long`
  `toNtfsTime(FileTime fileTime)`
  Deprecated.
  Use `FileTimes.toNtfsTime(FileTime)`.
  `static long`
  `toNtfsTime(Date date)`
  Deprecated.
  Use `FileTimes.toNtfsTime(Date)`.
  `static long`
  `toUnixTime(FileTime fileTime)`
  Deprecated.
  Use `FileTimes.toUnixTime(FileTime)`.
  `static FileTime`
  `truncateToHundredNanos(FileTime fileTime)`
  Deprecated.
  No replacement, only used in tests.
  `static FileTime`
  `unixTimeToFileTime(long time)`
  Deprecated.
  Use `FileTimes.fromUnixTime(long)`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### isUnixTime

    @Deprecated public static boolean isUnixTime(FileTime time)
    Deprecated.
    use `FileTimes.isUnixTime(FileTime)`
    Tests whether a FileTime can be safely represented in the standard Unix time.
    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 public static boolean isUnixTime(long seconds)
    Deprecated.
    Use `FileTimes.isUnixTime(long)`
    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 public static Date ntfsTimeToDate(long ntfsTime)
    Deprecated.
    Use `FileTimes.ntfsTimeToDate(long)`.
    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 public static FileTime ntfsTimeToFileTime(long ntfsTime)
    Deprecated.
    Use `FileTimes.ntfsTimeToFileTime(long)`.
    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:
      - `FileTimes.toNtfsTime(FileTime)`

  - ### toDate

    @Deprecated public static Date toDate(FileTime fileTime)
    Deprecated.
    Use `FileTimes.toDate(FileTime)`.
    Converts `FileTime` to a `Date`. If the provided FileTime is `null`, the returned Date is also `null`.
    Parameters:
      `fileTime` - the file time to be converted.
    Returns:
      a `Date` which corresponds to the supplied time, or `null` if the time is `null`.
    See Also:
      - `FileTimes.toFileTime(Date)`

  - ### toFileTime

    @Deprecated public static FileTime toFileTime(Date date)
    Deprecated.
    Use `FileTimes.toFileTime(Date)`.
    Converts `Date` to a `FileTime`. If the provided Date is `null`, the returned FileTime is also `null`.
    Parameters:
      `date` - the date to be converted.
    Returns:
      a `FileTime` which corresponds to the supplied date, or `null` if the date is `null`.
    See Also:
      - `FileTimes.toDate(FileTime)`

  - ### toNtfsTime

    @Deprecated public static long toNtfsTime(Date date)
    Deprecated.
    Use `FileTimes.toNtfsTime(Date)`.
    Converts a `Date` to NTFS time.
    Parameters:
      `date` - the Date.
    Returns:
      the NTFS time.

  - ### toNtfsTime

    @Deprecated public static long toNtfsTime(FileTime fileTime)
    Deprecated.
    Use `FileTimes.toNtfsTime(FileTime)`.
    Converts a `FileTime` to NTFS time (100-nanosecond units since 1 January 1601).
    Parameters:
      `fileTime` - the FileTime.
    Returns:
      the NTFS time in 100-nanosecond units.
    See Also:
      - `FileTimes.ntfsTimeToFileTime(long)`

  - ### toNtfsTime

    @Deprecated public static long toNtfsTime(long javaTime)
    Deprecated.
    Use `FileTimes.toNtfsTime(long)`
    Converts Java time (milliseconds since Epoch) to NTFS time.
    Parameters:
      `javaTime` - the Java time.
    Returns:
      the NTFS time.

  - ### toUnixTime

    @Deprecated public static long toUnixTime(FileTime fileTime)
    Deprecated.
    Use `FileTimes.toUnixTime(FileTime)`.
    Converts a `FileTime` to standard Unix time in seconds.

    The returned seconds value may lie out of bounds of Unix time. Check with `FileTimes.isUnixTime(long)`.

    Parameters:
      `fileTime` - the original FileTime.
    Returns:
      the Unix timestamp or 0 if the input is null.
    See Also:
      - `FileTimes.isUnixTime(long)`

  - ### truncateToHundredNanos

    @Deprecated public static FileTime truncateToHundredNanos(FileTime fileTime)
    Deprecated.
    No replacement, only used in tests.
    Truncates a FileTime to 100-nanosecond precision.
    Parameters:
      `fileTime` - the FileTime to be truncated.
    Returns:
      the truncated FileTime.

  - ### unixTimeToFileTime

    @Deprecated public static FileTime unixTimeToFileTime(long time)
    Deprecated.
    Use `FileTimes.fromUnixTime(long)`
    Converts standard Unix time (in seconds, UTC/GMT) to `FileTime`.
    Parameters:
      `time` - Unix timestamp (in seconds, UTC/GMT).
    Returns:
      the corresponding FileTime.