[text] 11860 Its a time zone change on December 31st in Shanghai See Lhis page for details of 1927 in Shanghai Basically at midnight at the end of 1927 the clocks went back 5 minutes and 52 seconds. So 19271231 235408 actually happened twice and it looks like Java is parsing it as the later possible instant for that local datetime hence the difference. Just another episode in the often weird and wonderful world of time zones. If rebuilt with version 2013a of TZDB The original question would no longer demonstrate quite the same behaviour. In 20133 the result would be 358 seconds with a transition time of 235403 instead of 235408. only noticed this because Im collecting questions like this in Noda Time in the form of unit tests… The test has now been changed but it just goes to show not even historical data is safe. In TZDB 2014f the time of the change has moved to 19001231 and its now a mere 343 second change so the time between t and t1 is 344 seconds if you see what mean. To answer a question around a transition at 1900… it looks like the Java time zone implementation treats all time zones as simply being in their standard time for any instant before the start of 1900 UTC import java.util.TimeZone public class Test public static void mainString args throws Exception long start0f19e6Utc 2208988806000L for String id TimeZone.getAvailableIDs TimeZone zone TimeZone.getTimeZoneid if zone.getRawOffset zone.getOffsetstart0f1906Utc 1 System.out.printlnid The code above produces no output on my Wwindows machine. So any time zone which has any offset other than its standard one at the start of 1900 will count that as a transition. TZDB itself has some data going back earlier than that and doesnt rely on any idea of a fixed standard time which is what getRawOffset assumes to be a valid concept so other libraries neednt introduce this artificial transition. Share Follow edited Mar 27 2023 at 1945 answered Jul 27 2011 at 831 VLAZ Jon Skeet 27.2k 9 54 72 1.4m 873 9186 9237 b u l accuate
in Backend, Debugging, Java, StackOverflow, Testing