Java-查找使用中的tzdata版本,而不考虑JRE版本 [英] Java - find tzdata version in use regardless of JRE version

查看:34
本文介绍了Java-查找使用中的tzdata版本,而不考虑JRE版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个简单的实用程序应用程序,可读取JRE中使用的所有时区数据并将其全部显示在简单表中.我们需要在即将发布的产品版本中使用JRE的较旧版本(6_24)(显然是由于其他问题),但是我们还需要在该版本中包含较新的时区更新(否则将包含在6_29中)).我们已经打包了将要安装的私有JRE,因此可以使用 TimeZone 类,但似乎未提供此信息-也许有一个保存此信息的系统属性?TZUpdater工具知道正在使用哪个版本,因此它必须在某个地方可用-我无法想象他们会分析性地确定更新工具中正在使用哪个版本...有人知道该信息在哪里吗?

解决方案

在我的一个JRE中, JRE_PATH \ lib \ zi 中有一个名为 ZoneInfoMappings 的文件.在第一行中,它将显示您要查找的数据.

我将寻找一种不太骇人听闻的方法,如果发现某些问题,它将更新答案.

更新:似乎没有API可以获取此数据.但是,类 sun.util.calendar.ZoneInfoFile 中的代码显示了如何解析它.

We have a simple utility app that reads all the time zone data used in a JRE and displays it all in a simple table. We need to use an older version of the JRE (6_24) for an upcoming product release (due to other issues apparently), but we also need to include newer time zone updates in that release (that would otherwise be included in, say, 6_29). We're already packaging a private JRE that will be installed, so getting the time zone updates into that private JRE using the TZUpdater tool is not the issue - The issue is reading/verifying which version of the tzdata (e.g. tzdata2010o, tzdata2011k) is being read with the utility app (i.e. which version is being used in the JRE the app is running in). The app currently displays the JRE version in the title bar, but with the time zone updates, that's no longer sufficient to determine which time zone data version is in use.

I've looked into the TimeZone class, but it doesn't seem to provide this information - perhaps there is a system property that holds this info? The TZUpdater tool knows which version is being used, so it must be available somewhere - I can't imagine they would analytically determine which version is in use in the update tool... Anybody know where to locate this info?

解决方案

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.

这篇关于Java-查找使用中的tzdata版本,而不考虑JRE版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆