39 |
package java.util.zip; |
package java.util.zip; |
40 |
|
|
41 |
import java.util.Calendar; |
import java.util.Calendar; |
|
import java.util.Date; |
|
42 |
|
|
43 |
/** |
/** |
44 |
* This class represents a member of a zip archive. ZipFile and |
* This class represents a member of a zip archive. ZipFile and |
172 |
Calendar cal = getCalendar(); |
Calendar cal = getCalendar(); |
173 |
synchronized (cal) |
synchronized (cal) |
174 |
{ |
{ |
175 |
cal.setTime(new Date(time)); |
cal.setTimeInMillis(time); |
176 |
dostime = (cal.get(Calendar.YEAR) - 1980 & 0x7f) << 25 |
dostime = (cal.get(Calendar.YEAR) - 1980 & 0x7f) << 25 |
177 |
| (cal.get(Calendar.MONTH) + 1) << 21 |
| (cal.get(Calendar.MONTH) + 1) << 21 |
178 |
| (cal.get(Calendar.DAY_OF_MONTH)) << 16 |
| (cal.get(Calendar.DAY_OF_MONTH)) << 16 |
189 |
*/ |
*/ |
190 |
public long getTime() |
public long getTime() |
191 |
{ |
{ |
192 |
|
// The extra bytes might contain the time (posix/unix extension) |
193 |
|
parseExtra(); |
194 |
|
|
195 |
if ((known & KNOWN_TIME) == 0) |
if ((known & KNOWN_TIME) == 0) |
196 |
return -1; |
return -1; |
197 |
|
|
|
// The extra bytes might contain the time (posix/unix extension) |
|
|
parseExtra (); |
|
|
|
|
198 |
int sec = 2 * (dostime & 0x1f); |
int sec = 2 * (dostime & 0x1f); |
199 |
int min = (dostime >> 5) & 0x3f; |
int min = (dostime >> 5) & 0x3f; |
200 |
int hrs = (dostime >> 11) & 0x1f; |
int hrs = (dostime >> 11) & 0x1f; |
208 |
synchronized (cal) |
synchronized (cal) |
209 |
{ |
{ |
210 |
cal.set(year, mon, day, hrs, min, sec); |
cal.set(year, mon, day, hrs, min, sec); |
211 |
return cal.getTime().getTime(); |
return cal.getTimeInMillis(); |
212 |
} |
} |
213 |
} |
} |
214 |
catch (RuntimeException ex) |
catch (RuntimeException ex) |
366 |
catch (ArrayIndexOutOfBoundsException ex) |
catch (ArrayIndexOutOfBoundsException ex) |
367 |
{ |
{ |
368 |
/* be lenient */ |
/* be lenient */ |
|
return; |
|
369 |
} |
} |
370 |
|
|
371 |
known |= KNOWN_EXTRA; |
known |= KNOWN_EXTRA; |
372 |
|
return; |
373 |
} |
} |
374 |
|
|
375 |
/** |
/** |