-1

On my local configuration (Eclipse 4.11 (2019.03), java runtime 1.8.0, SDK 1.8.0), when converting a local date & time (provided through separate strings) to a CET ZonedDateTime (using an intermediary LocalDateTime built from those strings), I get the following outputs :

input : "2001-10-26" and "21:32:52" => output : 2001-10-26T21:32:52+02:00[CET]
input : "-2001-10-26" and "21:32:52" => output :-2001-10-26T21:32:52+01:00[CET]

So, we see that the UTC offset is not the same. Of course, we refer to a moment in time where "UTC" and "UTC offset" had not yet been defined... However, I guess that java designers have implemented some rules for those cases as java process them anyway. Could someone give me some enlighten about this ? I have already seen this interesting post Java 8 - tz database time zones but it stays rather vague.

Thanks for helping me with this !

Jagadesh
  • 2,104
  • 1
  • 16
  • 28
jlm1150
  • 39
  • 1
  • 3
  • 3
    Timezone information is usually "correct" back until about 1900. Before that the very concept of "timezone" becomes vague. No timezone (except maybe for UTC and other fixed ones) has a useful definition for the year -2000. – Joachim Sauer Oct 13 '21 at 11:29
  • @JoachimSauer Actually the time zone database ([tzdb*](https://en.wikipedia.org/wiki/Tz_database)) is really only accurate back to around 1970, as mentioned in the Wikipedia page. Amazingly, afaik, no officials ever kept good records of time zones. David Olson and others have spent years piecing them together, retroactively. They have focused on the more recent decades. – Basil Bourque Oct 13 '21 at 23:14
  • @jlm1150 I would add that even the idea of tracking date-time values down to the minute or second from past millennia is dubious. I cannot imagine any practical application. – Basil Bourque Oct 13 '21 at 23:17

1 Answers1

2

The timezone rules are provided through the abstract ZoneRulesProvider class. The docs mention the default implementation in the ZoneRulesProvider's class description.

The Java virtual machine has a default provider that provides zone rules for the time-zones defined by IANA Time Zone Database (TZDB)

So all rules are originating from the time zone database maintained by IANA, and a copy of it is shipped with the JVM.

For all timezones, the tz database has rules defined, the transitions of when the time on the clock has changed or will change. This way, one could determine what date and time it was or will be on an arbitrary moment on the timeline.

So on 26 October −20011, the UTC offset was apparently +01:00.

I have to add two things. First, I would believe the data from the tzdb, because its maintainers probably have a better understanding of how timezones and their rules work. Second, as Joachim already mentioned in the comments, timezones are a concept that was invented a century ago, so combining timezoned with years like −2001 makes a little sense.


1 Note that the calendar used by most of the people in the world is the Gregorian calendar. In the year −2001, that calendar wasn't invented yet. The java.time package uses the proleptic Gregorian calendar.

MC Emperor
  • 22,334
  • 15
  • 80
  • 130