是Joda-Time提供一种识别其版本的方法吗?
对于调试、日志记录等,最好能够识别运行时使用的 Joda-Time 版本。
我尝试使用Google搜索文档(site:www.joda.org/joda-time/apidocs/version
),但没有找到所需的方法。
最佳答案
如果您的Joda Time包含Maven信息,您可以使用以下代码提取版本:
String version = null;
try (InputStream in = DateTime.class.getResourceAsStream("/META-INF/maven/joda-time/joda-time/pom.properties")) {
if (in != null) {
Properties p = new Properties();
p.load(in);
version = p.getProperty("version");
}
} catch (IOException ignore) {}
System.out.println(version);
关于java - 在运行时识别当前使用的 Joda-Time 库的版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30988557/