Repository navigation
Conversation
Time.getIsoTimeString used the XXX offset pattern, which drops the seconds of historical offsets such as Africa/Monrovia's -00:44:30, so the printed text parsed back to a different instant (30 s off for the mainnet genesis time 0). Use XXXXX, which prints the seconds only when the offset has them and keeps +08:00 and Z unchanged, matching joda-time's DateTime.toString() again.
|
[NIT] Consider adding a DST-overlap case and representative default-zone IDs outside For example, in |
Thanks, added both in a4c63f9: a DST-overlap case ( |
What does this PR do?
Changes the offset pattern of
Time.getIsoTimeStringfromXXXtoXXXXX, so an offset that includes seconds is printed in full, e.g.-00:44:30. Whole-minute offsets print as before (Z,+08:00). AddsTimeTest.Why are these changes required?
#6950 replaced Joda-Time with
Time.getIsoTimeString.XXXprints only hours and minutes, so a historical offset with seconds is truncated and the printed text no longer denotes the logged instant.Before this change, with
Africa/Monroviaas the JVM default zone, epoch0was logged as1969-12-31T23:15:30.000-00:44, which parses back to -30000 ms. Joda-Time printed1969-12-31T23:15:30.000-00:44:30, and so does this change.Epoch
0is the mainnet genesis timestamp. On a node starting from an empty database,DynamicPropertiesStoresets the next maintenance time to it, and applying block 1 makes the firstupdateNextMaintenanceTimecall, which logs it ascurrentMaintenanceTime.Only log text is affected. Block times, the maintenance calculation and stored values do not change.
This PR has been tested by:
TimeTestchecks thatAfrica/Monroviakeeps the offset seconds, that UTC (Z) andAsia/Shanghai(+08:00) output is unchanged, and that for every zone inZoneId.getAvailableZoneIds()the output for1900-01-01T00:00:00Z, epoch 0 and a 2023 sample with nonzero milliseconds parses back to the same millisecond. Two of the threeTimeTestmethods fail withXXX.:common:testpasses on JDK 17 / arm64.XXXXX, all 1,710 values per JDK round-trip withOffsetDateTime.parse, and the output is byte-identical wherever both libraries resolve the same offset. WithXXX, 335 values fail to round-trip on JDK 8 and 332 on JDK 17.Follow up
The related Logback 1.3 compatibility notes from #6950 (
%dzone IDs andS, JVM default zones beyond ±18:00) are documented in #6950's description and are not changed here.Extra details
XXXXXprints hours, minutes and optional seconds with colons, andZfor a zero offset. It is supported byDateTimeFormattersince JDK 8.