andrebrait commented on code in PR #345:
URL: https://github.com/apache/commons-compress/pull/345#discussion_r1059194898
##########
src/main/java/org/apache/commons/compress/utils/TimeUtils.java:
##########
@@ -46,6 +46,62 @@ public final class TimeUtils {
*/
static final long WINDOWS_EPOCH_OFFSET = -116444736000000000L;
+ /**
+ * Converts "standard UNIX time" (in seconds, UTC/GMT) to {@link FileTime}.
+ *
+ * @param time UNIX timestamp
+ * @return the corresponding FileTime
+ */
+ public static FileTime unixTimeToFileTime(final long time) {
+ return FileTime.from(time, TimeUnit.SECONDS);
+ }
+
+ /**
+ * Converts {@link FileTime} to "standard UNIX time".
+ *
+ * @param time the original FileTime
+ * @return the UNIX timestamp
+ */
+ public static long fileTimeToUnixTime(final FileTime time) {
+ return time.to(TimeUnit.SECONDS);
+ }
+
+ /**
+ * Converts Java time (milliseconds since Epoch) to "standard UNIX time".
+ *
+ * @param time the original Java time
+ * @return the UNIX timestamp
+ */
+ public static long javaTimeToUnixTime(final long time) {
+ return time / 1000L;
+ }
+
+ /**
+ * Checks whether a FileTime exceeds the minimum or maximum for the
"standard UNIX time".
+ * If the FileTime is null, this method always returns false.
+ *
+ * @param time the FileTime to evaluate, can be null
+ * @return true if the time exceeds the minimum or maximum UNIX time,
false otherwise
+ */
+ public static boolean exceedsUnixTime(final FileTime time) {
Review Comment:
I think it could be negated and called "fitsInUnixTime" or something like
that? Or maybe "isUnixTime" (but also negated)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]