-
public abstract class ZipUtilUtility class for handling DOS and Java time conversions.
-
-
Method Summary
Modifier and Type Method Description static longadjustToLong(int i)Assumes a negative integer really is a positive integer thathas wrapped around and re-creates the original value. static longdosToJavaTime(long dosTime)Converts DOS time to Java time (number of milliseconds sinceepoch). static DatefromDosTime(ZipLong zipDosTime)Convert a DOS date/time field to a Date object. static Array<byte>reverse(Array<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 ZipLongtoDosTime(Date time)Convert a Date object to a DOS date/time field. static Array<byte>toDosTime(long t)Convert a Date object to a DOS date/time field. static voidtoDosTime(long t, Array<byte> buf, int offset)Convert 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). -
-
Method Detail
-
adjustToLong
static long adjustToLong(int i)
Assumes a negative integer really is a positive integer thathas wrapped around and re-creates the original value.
- Parameters:
i- the value to treat as unsigned int.
-
dosToJavaTime
static long dosToJavaTime(long dosTime)
Converts DOS time to Java time (number of milliseconds sinceepoch).
- Parameters:
dosTime- time to convert
-
fromDosTime
static Date fromDosTime(ZipLong zipDosTime)
Convert a DOS date/time field to a Date object.
- Parameters:
zipDosTime- contains the stored DOS time.
-
reverse
static Array<byte> reverse(Array<byte> array)
Reverses a byte[] array. Reverses in-place (thus provided array ismutated), but also returns same for convenience.
- Parameters:
array- to reverse (mutated in-place, but also returned forconvenience).
-
signedByteToUnsignedInt
static int signedByteToUnsignedInt(byte b)
Converts a signed byte into an unsigned integer representation(e.g., -1 becomes 255).
- Parameters:
b- byte to convert to int
-
toDosTime
static ZipLong toDosTime(Date time)
Convert a Date object to a DOS date/time field.
- Parameters:
time- the{@code Date}to convert
-
toDosTime
static Array<byte> toDosTime(long t)
Convert a Date object to a DOS date/time field.
Stolen from InfoZip's
{@code fileio.c}- Parameters:
t- number of milliseconds since the epoch
-
toDosTime
static void toDosTime(long t, Array<byte> buf, int offset)
Convert a Date object to a DOS date/time field.
Stolen from InfoZip's
{@code 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.
-
unsignedIntToSignedByte
static byte unsignedIntToSignedByte(int i)
Converts an unsigned integer to a signed byte (e.g., 255 becomes -1).
- Parameters:
i- integer to convert to byte
-
-
-
-