de.schlichtherle.util.zip
Class DateTimeConverter

java.lang.Object
  extended by de.schlichtherle.util.zip.DateTimeConverter

public abstract class DateTimeConverter
extends Object

Converts Java time values to DOS date/time values and vice versa. This class has been introduced in order to enhance interoperability between different flavours of the ZIP file format specification when converting date/time from the serialized DOS format in a ZIP file to the local system time, which is represented by a UNIX-like encoding by the Java API.

This class is thread-safe.

Since:
TrueZIP 6.7
Version:
TrueZIP 6.7
Author:
Christian Schlichtherle

Field Summary
static DateTimeConverter JAR
          This instance applies the schedule for Daylight Saving Time (DST), i.e. all time conversions will apply DST where appropriate to a particular date.
static DateTimeConverter ZIP
          This instance ignores the schedule for Daylight Saving Time (DST), i.e. all time conversions will use the same raw offset and current DST savings, regardless of whether DST savings should be applied to a particular date or not.
 
Constructor Summary
DateTimeConverter()
           
 
Method Summary
protected abstract  TimeZone createTimeZone()
          Returns a new timezone to use for date/time conversion.
protected abstract  boolean roundUp(long jTime)
          Returns whether a Java time should be rounded up or down to the next two second interval when converting it to a DOS date/time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JAR

public static final DateTimeConverter JAR
This instance applies the schedule for Daylight Saving Time (DST), i.e. all time conversions will apply DST where appropriate to a particular date.

This behaviour provides best interoperability with:


ZIP

public static final DateTimeConverter ZIP
This instance ignores the schedule for Daylight Saving Time (DST), i.e. all time conversions will use the same raw offset and current DST savings, regardless of whether DST savings should be applied to a particular date or not.

This behavior provides best interoperability with:

Constructor Detail

DateTimeConverter

public DateTimeConverter()
Method Detail

createTimeZone

protected abstract TimeZone createTimeZone()
Returns a new timezone to use for date/time conversion. All returned instances must have the same rules.

Returns:
A new timezone for date/time conversion - never null.

roundUp

protected abstract boolean roundUp(long jTime)
Returns whether a Java time should be rounded up or down to the next two second interval when converting it to a DOS date/time.

Parameters:
jTime - The number of milliseconds since midnight, January 1st, 1970 AD UTC (called the epoch alias Java time).
Returns:
yes for round-up, no for round-down.