java - 如何自动将编译日期添加到java项目中

标签 java date compilation

Java 中有没有办法让字符串包含程序编译的日期?当我启动程序时,我希望显示上次更新的日期,而不必在每次编译之前手动更新它。 eclipse 中是否有一个设置可以用来在每次编译代码时在代码中插入日期?

public class test {
    public static void main(String[] args) {

        String date = "2014-12-29"; //The string I want to automatically update.

        System.out.println("Last updated: "+date);

    }
}

最佳答案

将包含日期的文件添加到您的项目中。开始时从文件中读取它。使用 Gradle、Maven 或 Ant 等工具来构建您的项目。他们都有一种方法来更新文件的日期。

关于java - 如何自动将编译日期添加到java项目中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27692543/

相关文章:

java - 如何修复 Android 中无法解析方法 'setContentView'

java - 从Python服务器到Android客户端的图像数据丢失(Endian问题??)

MySQL 面试 q : make a query that adds the number of worked hours in a given time period and display the name and total no. 工作时间

c - 每个.h文件都有一个对应的目标文件吗?

apache - 如何编译 libmesos.so 文件?

java - 了解如何使用 Jython 的问题

java - 将 ArrayList 从 Activity 传递到 CustomDialog

Java图(结构)深拷贝

mysql - 在两个日期之间随机更新mysql日期

r - ggplot2 和 plotly 悬停的日期格式