TimeZone tz = TimeZone.getTimeZone("Asia/Shanghai"); // dos time does not support < 1980, have to use // utc in mtime.
testWithTZ(tz, ldt.withYear(1982));
testWithTZ(tz, ldt.withYear(2037));
testWithTZ(tz, ldt.withYear(2100));
testWithTZ(tz, ldt.withYear(2106));
staticvoid check(ZipEntry ze, LocalDateTime expected) {
LocalDateTime ldt = ze.getTimeLocal(); if (ldt.atOffset(ZoneOffset.UTC).toEpochSecond() >> 1
!= expected.atOffset(ZoneOffset.UTC).toEpochSecond() >> 1) { // if the LDT is out of the range of the standard ms-dos date-time // format ( < 1980 ) AND the date-time is within the daylight saving // time gap (which means the LDT is actually "invalid"), the LDT will // be adjusted accordingly when ZipEntry.setTimeLocal() converts the // date-time via ldt -> zdt -> Instant -> FileTime. // See ZonedDateTime.of(LocalDateTime, ZoneId) for more details. if (ldt.getYear() < 1980 || ldt.getYear() > (1980 + 0x7f)) {
System.out.println(" Non-MSDOS ldt : " + ldt);
System.out.println(" expected : " + expected); // try to adjust the "expected", assume daylight saving gap
expected = ZonedDateTime.of(expected, ZoneId.systemDefault())
.toLocalDateTime(); if (ldt.atOffset(ZoneOffset.UTC).toEpochSecond() >> 1
== expected.atOffset(ZoneOffset.UTC).toEpochSecond() >> 1) { return;
}
} thrownew RuntimeException("Timestamp: storing mtime failed!");
}
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.