1

Does Joda-Time offer a method to identify its version?

For debugging, logging, and such, it would be nice to identify the version of Joda-Time in use at runtime.

I tried using Google to search the doc (site:www.joda.org/joda-time/apidocs/ version), but did not find the desired method.

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154

1 Answers1

1

If your Joda Time contains Maven information, you can use the following code to extract the version:

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);
Brian
  • 872
  • 8
  • 16