maven pdf插件:以pdf格式显示本地时间
我正在使用maven 2.2.1和maven pdf插件在“mvn站点”期间生成我的surefire报告的pdf版本 我希望在PDF本身中显示报告(即PDF)生成时间戳,但显示在我的本地时区中,而不是UTC中。我的本地时区是UTC+5:30(IST) 以下是mypom.xml中build/plugins部分的一个片段:maven pdf插件:以pdf格式显示本地时间,maven,maven-2,timezone,maven-pdf-plugin,Maven,Maven 2,Timezone,Maven Pdf Plugin,我正在使用maven 2.2.1和maven pdf插件在“mvn站点”期间生成我的surefire报告的pdf版本 我希望在PDF本身中显示报告(即PDF)生成时间戳,但显示在我的本地时区中,而不是UTC中。我的本地时区是UTC+5:30(IST) 以下是mypom.xml中build/plugins部分的一个片段: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifa
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pdf-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>pdf</id>
<phase>site</phase>
<goals>
<goal>pdf</goal>
</goals>
<configuration>
<aggregate>true</aggregate>
<generateTOC>none</generateTOC>
<outputDirectory>${project.reporting.outputDirectory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
org.apache.maven.plugins
,例如:
${dateTime}
及
${day}/${month}/${year}-${hour}:${minute}:${second}
但生成的时间戳始终为UTC
我还尝试了一些尝试,如${dateTime+5:30}
,但这不起作用
我试图在coverdate
中插入${maven.build.timestamp}
(如果在我的pom中使用它,它实际上是在我的本地时间),但在生成PDF时不会插入
如何获取本地时区的时间戳?我甚至不需要
部分;如果我能以某种方式在PDF中添加构建时间戳,我就可以完全摆脱它。我找到了一种迂回的方法来实现这一点
我将我的时区特定时间戳放在pom的描述标签中,如下所示:
<description>${maven.build.timestamp}</description>
<properties>
<maven.build.timestamp.format>E dd-MMM-yyyy HH:mm z</maven.build.timestamp.format>
</properties>
${maven.build.timestamp}
E dd MMM yyyy HH:mm z
现在我可以告诉pdf插件将其插入coverdate。My pdf.xml有以下内容:
<cover>
<coverTitle>My Cover Title</coverTitle>
<coverdate>${project.description}</coverdate>
...
</cover>
我的封面标题
${project.description}
...
现在,我在PDF封面上获得了所需的时间戳,以本地时间为单位,格式如我所愿
诚然,在pom的描述标签中插入时间戳并不是件好事,但是因为我没有将描述标签用于其他任何事情,所以我可以接受它
不幸的是,我无法访问pdf.xml中的任意${project.X}属性。。。只有少数属性,如${project.name}和${project.description}似乎有效
<cover>
<coverTitle>My Cover Title</coverTitle>
<coverdate>${project.description}</coverdate>
...
</cover>