Class ZipUtil
java.lang.Object
org.apache.commons.compress.archivers.zip.ZipUtil
Utility class for handling DOS and Java time conversions.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic longadjustToLong(int i) Assumes a negative integer really is a positive integer that has wrapped around and re-creates the original value.static longdosToJavaTime(long dosTime) Converts DOS time to Java time (number of milliseconds since epoch).static DatefromDosTime(ZipLong zipDosTime) Convert a DOS date/time field to a Date object.static byte[]reverse(byte[] array) Reverses a byte[] array.static intsignedByteToUnsignedInt(byte b) Converts a signed byte into an unsigned integer representation (e.g., -1 becomes 255).static byte[]toDosTime(long t) Convert a Date object to a DOS date/time field.static voidtoDosTime(long t, byte[] buf, int offset) Convert a Date object to a DOS date/time field.static ZipLongConvert a Date object to a DOS date/time field.static byteunsignedIntToSignedByte(int i) Converts an unsigned integer to a signed byte (e.g., 255 becomes -1).
-
Constructor Details
-
ZipUtil
public ZipUtil()
-
-
Method Details
-
toDosTime
Convert a Date object to a DOS date/time field.- Parameters:
time- theDateto convert- Returns:
- the date as a
ZipLong
-
toDosTime
Convert a Date object to a DOS date/time field.Stolen from InfoZip's
fileio.c- Parameters:
t- number of milliseconds since the epoch- Returns:
- the date as a byte array
-
toDosTime
Convert a Date object to a DOS date/time field.Stolen from InfoZip's
fileio.c- Parameters:
t- number of milliseconds since the epochbuf- the output bufferoffset- The offset within the output buffer of the first byte to be written. must be non-negative and no larger thanbuf.length-4
-
adjustToLong
Assumes a negative integer really is a positive integer that has wrapped around and re-creates the original value.- Parameters:
i- the value to treat as unsigned int.- Returns:
- the unsigned int as a long.
-
reverse
Reverses a byte[] array. Reverses in-place (thus provided array is mutated), but also returns same for convenience.- Parameters:
array- to reverse (mutated in-place, but also returned for convenience).- Returns:
- the reversed array (mutated in-place, but also returned for convenience).
- Since:
- 1.5
-
signedByteToUnsignedInt
Converts a signed byte into an unsigned integer representation (e.g., -1 becomes 255).- Parameters:
b- byte to convert to int- Returns:
- int representation of the provided byte
- Since:
- 1.5
-
unsignedIntToSignedByte
Converts an unsigned integer to a signed byte (e.g., 255 becomes -1).- Parameters:
i- integer to convert to byte- Returns:
- byte representation of the provided int
- Throws:
IllegalArgumentException- if the provided integer is not inside the range [0,255].- Since:
- 1.5
-
fromDosTime
Convert a DOS date/time field to a Date object.- Parameters:
zipDosTime- contains the stored DOS time.- Returns:
- a Date instance corresponding to the given time.
-
dosToJavaTime
Converts DOS time to Java time (number of milliseconds since epoch).- Parameters:
dosTime- time to convert- Returns:
- converted time
-