JAVA_build_ant_Tstamp

本文详细介绍了Ant构建工具中TStamp任务的使用方法及其参数设置。TStamp任务可用于设置当前项目的DSTAMP、TSTAMP和TODAY属性,并允许通过<format>元素指定不同的日期时间格式。此外,文章还提供了多个实例来展示如何利用该任务创建带有时间戳的文件名或替换文档中的占位符。

 

Description

Sets the DSTAMPTSTAMP, and TODAY properties in the current project. By default, the DSTAMP property is in the format "yyyyMMdd", TSTAMP is in the format "hhmm", and TODAY is in the format "MMMM dd yyyy". Use the nested <format> element to specify a different format.

These properties can be used in the build-file, for instance, to create time-stamped filenames, or used to replace placeholder tags inside documents to indicate, for example, the release date. The best place for this task is probably in an initialization target.

Parameters

AttributeDescriptionRequired
prefixPrefix used for all properties set. The default is no prefix.No

Nested Elements

The Tstamp task supports a <format> nested element that allows a property to be set to the current date and time in a given format. The date/time patterns are as defined in the Java SimpleDateFormat class. The format element also allows offsets to be applied to the time to generate different time values. 

AttributeDescriptionRequired
propertyThe property to receive the date/time string in the given pattern.Yes
patternThe date/time pattern to be used. The values are as defined by the Java SimpleDateFormat class.Yes
timezoneThe timezone to use for displaying time. The values are as defined by the Java TimeZone class.No
offsetThe numeric offset to the current timeNo
unitThe unit of the offset to be applied to the current time. Valid Values are
  • millisecond
  • second
  • minute
  • hour
  • day
  • week
  • month
  • year
No
localeThe locale used to create date/time string. The general form is "language, country, variant" but either variant or variant and country may be omitted. For more information please refer to documentation for the Locale class.No

Examples

  <tstamp/>

sets the standard DSTAMPTSTAMP, and TODAY properties according to the default formats.

  <tstamp>
    <format property="TODAY_GB" pattern="d-MMMM-yyyy" locale="en,GB"/>
  </tstamp>

sets the standard properties as well as the property TODAY_UK with the date/time pattern "d-MMMM-yyyy" using English locale (eg. 21-May-2001).

  <tstamp>
      <format property="touch.time" pattern="MM/dd/yyyy hh:mm aa"
              offset="-5" unit="hour"/>
  </tstamp>

Creates a timestamp, in the property touch.time, 5 hours before the current time. The format in this example is suitable for use with the <touch> task. The standard properties are set also.

  <tstamp prefix="start"/>

Sets three properties with the standard formats, prefixed with "start.": start.DSTAMPstart.TSTAMP, and start.TODAY.

转载于:https://www.cnblogs.com/liupuLearning/p/6133316.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值