build.xml 将日期和时间设置为文件名 [英] build.xml to set date and time as file name

查看:31
本文介绍了build.xml 将日期和时间设置为文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设置带有日期和时间的文件名,所以我想创建名为 behat-20140913-195915.html 的文件,但是下面的示例将名称设置为 behat-yyyymmdd-hhiiss.html.有人知道问题的解决方法吗?

I want to set file name with date and time attached to it so I want to create file named as behat-20140913-195915.html however the example below sets the name as behat-yyyymmdd-hhiiss.html. Anyone know the solution to problem?

我遵循了这个例子

注意:这两个也不起作用:${DSTAMP} ${TSTAMP}

<?xml version="1.0" encoding="UTF-8"?>

<project name="Sport" default="build-default" basedir=".">

    <tstamp>
        <format property="TODAY_MY" pattern="yyyymmdd-hhiiss"  locale="en,UK" />
    </tstamp>

    <target name="build" description="Runs everything in order ..." depends="behat-bdd" />

    <target name="behat">
        <echo msg="Running Behat tests ..." />
        <exec logoutput="true" checkreturn="true"
              command="bin/behat -f progress --format html --out ${dir-report}/behat-${TODAY_MY}.html" dir="./" />
    </target>

</project>

推荐答案

tstamp 任务被记录在案在ANT手册中.它描述了模式格式如何来自 SimpleDateFormat 对象:

The tstamp task is documented in the ANT manual. It describes how the pattern format comes from the SimpleDateFormat object:

我建议尝试以下方法:

Buildfile: build.xml

build:
     [echo] date: 20140913-203419

build.xml

<project name="demo" default="build">

  <tstamp>
      <format property="TODAY_MY" pattern="yyyyMMdd-HHmmss"  locale="en,UK" />
  </tstamp>

  <target name="build">
    <echo message="date: ${TODAY_MY}"/>
  </target>

</project>

软件版本

$ ant -v
Apache Ant(TM) version 1.9.4 compiled on April 29 2014

$ java -version
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)

这篇关于build.xml 将日期和时间设置为文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆