210 * extra data} in UTC time. The {@link java.time.ZoneId#systemDefault() 211 * system default TimeZone} is used to convert the local date-time 212 * to UTC time. 213 * 214 * <p> {@code LocalDateTime} uses a precision of nanoseconds, whereas 215 * this class uses a precision of milliseconds. The conversion will 216 * truncate any excess precision information as though the amount in 217 * nanoseconds was subject to integer division by one million. 218 * 219 * @param time 220 * The last modification time of the entry in local date-time 221 * 222 * @see #getTimeLocal() 223 * @since 9 224 */ 225 public void setTimeLocal(LocalDateTime time) { 226 int year = time.getYear() - 1980; 227 if (year < 0) { 228 this.xdostime = DOSTIME_BEFORE_1980; 229 } else { 230 this.xdostime = (year << 25 | 231 time.getMonthValue() << 21 | 232 time.getDayOfMonth() << 16 | 233 time.getHour() << 11 | 234 time.getMinute() << 5 | 235 time.getSecond() >> 1) 236 + ((long)(((time.getSecond() & 0x1) * 1000) + 237 time.getNano() / 1000_000) << 32); 238 } 239 if (xdostime != DOSTIME_BEFORE_1980 && year <= 0x7f) { 240 this.mtime = null; 241 } else { 242 this.mtime = FileTime.from( 243 ZonedDateTime.of(time, ZoneId.systemDefault()).toInstant()); 244 } 245 } 246 247 /** 248 * Returns the last modification time of the entry in local date-time. 249 * 250 * <p> If the entry is read from a ZIP file or ZIP file formatted 251 * input stream, this is the last modification time from the zip 252 * file entry's {@code optional extra data} if the extended timestamp 253 * fields are present. Otherwise, the last modification time is read 254 * from entry's standard MS-DOS formatted {@code date and time fields}. 255 * | 210 * extra data} in UTC time. The {@link java.time.ZoneId#systemDefault() 211 * system default TimeZone} is used to convert the local date-time 212 * to UTC time. 213 * 214 * <p> {@code LocalDateTime} uses a precision of nanoseconds, whereas 215 * this class uses a precision of milliseconds. The conversion will 216 * truncate any excess precision information as though the amount in 217 * nanoseconds was subject to integer division by one million. 218 * 219 * @param time 220 * The last modification time of the entry in local date-time 221 * 222 * @see #getTimeLocal() 223 * @since 9 224 */ 225 public void setTimeLocal(LocalDateTime time) { 226 int year = time.getYear() - 1980; 227 if (year < 0) { 228 this.xdostime = DOSTIME_BEFORE_1980; 229 } else { 230 this.xdostime = ((year << 25 | 231 time.getMonthValue() << 21 | 232 time.getDayOfMonth() << 16 | 233 time.getHour() << 11 | 234 time.getMinute() << 5 | 235 time.getSecond() >> 1) & 0xffffffffL) 236 + ((long)(((time.getSecond() & 0x1) * 1000) + 237 time.getNano() / 1000_000) << 32); 238 } 239 if (xdostime != DOSTIME_BEFORE_1980 && year <= 0x7f) { 240 this.mtime = null; 241 } else { 242 this.mtime = FileTime.from( 243 ZonedDateTime.of(time, ZoneId.systemDefault()).toInstant()); 244 } 245 } 246 247 /** 248 * Returns the last modification time of the entry in local date-time. 249 * 250 * <p> If the entry is read from a ZIP file or ZIP file formatted 251 * input stream, this is the last modification time from the zip 252 * file entry's {@code optional extra data} if the extended timestamp 253 * fields are present. Otherwise, the last modification time is read 254 * from entry's standard MS-DOS formatted {@code date and time fields}. 255 * |