蚂蚁:我怎么可以减去两个属性(包含时间戳)? [英] Ant: How can I subtract two properties (containing timestamps)?
本文介绍了蚂蚁:我怎么可以减去两个属性(包含时间戳)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我工作的一个Ant脚本。在这个特殊的一部分,我需要获得当月,以及前一个月。我想类似的东西,以
I'm working on an ant script. In this particular part, I need to get the current month, as well as the prior month. I was thinking something similar to
<tstamp>
<format property="thismonth" pattern="MMyy"/> <!-- 0210 by february 2010-->
</tstamp>
<!--I'd like to get 0110 (january 2010) here, but can't imagine how-->
<property name="priormonth" value="?">
我一直在读的财产助手,但我不能得到我所需要的。
有任何想法吗?
I've been reading on property helpers, but I cant get what I need. Any ideas?
先谢谢了。
推荐答案
您可以用自定义做的JavaScript的 scriptdef :
You can do it with a custom JavaScript scriptdef:
<project default="build">
<target name="build">
<echo message="Hello world"/>
<setdates/>
<echo message="thismonth ${thismonth}"/>
<echo message="priormonth ${priormonth}"/>
</target>
<scriptdef name="setdates" language="javascript">
<![CDATA[
importClass(java.text.SimpleDateFormat);
importClass(java.util.Calendar);
today = new Date();
cal = Calendar.getInstance();
cal.setTime(today);
cal.set(Calendar.MONTH, cal.get(Calendar.MONTH) - 1);
priormonth = cal.getTime();
fmt = new SimpleDateFormat("MMyy");
self.getProject().setProperty('thismonth', fmt.format(today));
self.getProject().setProperty('priormonth', fmt.format(priormonth));
]]>
</scriptdef>
</project>
这篇关于蚂蚁:我怎么可以减去两个属性(包含时间戳)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文