显示编译时间戳在应用程序 [英] Displaying the build time-stamp in an application
问题描述
我想显示当应用程序建在关于对话框的时间戳。这将让我跟踪不同版本的应用程序。我如何在Java中获取这些信息?
I would like to display the time-stamp of when the application was built in an about box. This will allow me tracking different versions of the application. How can I retrieve this information in Java?
推荐答案
有不需要的插件antrun一个更简单的Maven的解决方案。 Maven有一个特殊的变量maven.build.timestamp(因为Maven的2.1.0-M1)。
There's a much simpler maven solution which doesn't require the antrun plugin. Maven has a special variable maven.build.timestamp (since Maven 2.1.0-M1).
<plugin>
<artifactId>maven-war-plugin</artifactId> <!-- or maven-jar-plugin -->
<version>2.2</version>
<configuration>
<archive>
<manifestEntries>
<Build-Time>${maven.build.timestamp}</Build-Time>
</manifestEntries>
</archive>
</configuration>
</plugin>
这将产生一个线建设 - 时间:年月日-HHMM。格式可与可定制
This will produce a line "Build-Time: yyyyMMdd-HHmm". The format can be customized with:
<properties>
<maven.build.timestamp.format>yyyy-MM-dd HH:mm</maven.build.timestamp.format>
</properties>
模式必须符合SimpleDateFormat的格式。
The pattern has to comply with the format of SimpleDateFormat.
参考:<一href=\"http://maven.apache.org/guides/introduction/introduction-to-the-pom.html#Available_Variables\">Maven文档
这篇关于显示编译时间戳在应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!