Java - find tzdata version in use regardless of JRE version
In one of my JREs, there's a file in JRE_PATH\lib\zi
named ZoneInfoMappings
. In the first line it displays the data you are looking for.
I'm going to search for a less hackish way, will update answer if I find something.
UPDATE:
Seems that there's no API to get this data. However, the code in the class sun.util.calendar.ZoneInfoFile
shows how to parse it.
ZoneRulesProvider.getVersions
In Java 8, you can use ZoneRulesProvider.getVersions("UTC")
:
The exact meaning and format of the version is provider specific. The version must follow lexicographical order, thus the returned map will be order from the oldest known rules to the newest available rules. The default 'TZDB' group uses version numbering consisting of the year followed by a letter, such as '2009e' or '2012f'.
Example:
System.out.println(
java.time.zone.ZoneRulesProvider
.getVersions("UTC")
.lastEntry()
.getKey()
);
In my Oracle Java 8u91, I get:
2016a
See this code run live at IdeOne.com.