You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

tstamp.html 6.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <!--
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. -->
  15. <html>
  16. <head>
  17. <meta http-equiv="Content-Language" content="en-us">
  18. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  19. <title>TStamp Task</title>
  20. </head>
  21. <body>
  22. <h2 id="tstamp">Tstamp</h2>
  23. <h3>Description</h3>
  24. <p>Sets the <code>DSTAMP</code>, <code>TSTAMP</code>, and <code>TODAY</code>
  25. properties in the current project. By default,
  26. the <code>DSTAMP</code> property is in the
  27. format &quot;yyyyMMdd&quot;, <code>TSTAMP</code> is in the
  28. format &quot;hhmm&quot;, and <code>TODAY</code> is in the
  29. format &quot;MMMM dd yyyy&quot;. Use the nested <code>&lt;format&gt;</code> element
  30. to specify a different format.</p>
  31. <p>These properties can be used in the build-file, for instance, to create
  32. time-stamped filenames, or used to replace placeholder tags inside documents
  33. to indicate, for example, the release date. The best place for this task is
  34. probably in an initialization target.</p>
  35. <p><em>Since Ant 1.10.2</em> the magic
  36. property <code>ant.tstamp.now</code> can be used to specify a fixed
  37. date value in order to create reproducible builds. Its value must be
  38. a number and is interpreted as seconds since the epoch (midnight
  39. 1970-01-01). With <code>ant.tstamp.now.iso</code> you could also specify that
  40. value in ISO-8601 format (<code>1972-04-17T08:07:00Z</code>). If you specify a value
  41. in an invalid format an INFO message will be logged and the value will be ignored.</p>
  42. <h3>Parameters</h3>
  43. <table>
  44. <tr>
  45. <td valign="top"><b>Attribute</b></td>
  46. <td valign="top"><b>Description</b></td>
  47. <td align="center" valign="top"><b>Required</b></td>
  48. </tr>
  49. <tr>
  50. <td valign="top">prefix</td>
  51. <td valign="top">Prefix used for all properties set. The default is no prefix.</td>
  52. <td align="center" valign="top">No</td>
  53. </tr>
  54. </table>
  55. <h3>Nested Elements</h3>
  56. <p>
  57. The Tstamp task supports a <code>&lt;format&gt;</code> nested element that
  58. allows a property to be set to the current date and time in a given format.
  59. The date/time patterns are as defined in the Java
  60. <a href="http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html">SimpleDateFormat</a> class.
  61. The format element also allows offsets to be applied to the time to generate different time values.
  62. </p>
  63. <table>
  64. <tr>
  65. <td valign="top"><b>Attribute</b></td>
  66. <td valign="top"><b>Description</b></td>
  67. <td align="center" valign="top"><b>Required</b></td>
  68. </tr>
  69. <tr>
  70. <td valign="top">property</td>
  71. <td valign="top">
  72. The property to receive the date/time string in the given pattern.
  73. </td>
  74. <td align="center" valign="top">Yes</td>
  75. </tr>
  76. <tr>
  77. <td valign="top">pattern</td>
  78. <td valign="top">The date/time pattern to be used. The values are as defined by the Java SimpleDateFormat class.</td>
  79. <td align="center" valign="top">Yes</td>
  80. </tr>
  81. <tr>
  82. <td valign="top">timezone</td>
  83. <td valign="top">The timezone to use for displaying time. The values are as defined by the Java <a href="http://docs.oracle.com/javase/7/docs/api/java/util/TimeZone.html">TimeZone</a> class.</td>
  84. <td align="center" valign="top">No</td>
  85. </tr>
  86. <tr>
  87. <td valign="top">offset</td>
  88. <td valign="top">The numeric offset to the current time</td>
  89. <td align="center" valign="top">No</td>
  90. </tr>
  91. <tr>
  92. <td valign="top">unit</td>
  93. <td valign="top">The unit of the offset to be applied to the current time.
  94. Valid Values are
  95. <ul>
  96. <li>millisecond</li>
  97. <li>second</li>
  98. <li>minute</li>
  99. <li>hour</li>
  100. <li>day</li>
  101. <li>week</li>
  102. <li>month</li>
  103. <li>year</li>
  104. </ul>
  105. </td>
  106. <td align="center" valign="top">No</td>
  107. </tr>
  108. <tr>
  109. <td valign="top">locale</td>
  110. <td valign="top">The locale used to create date/time string. The general
  111. form is &quot;language, country, variant&quot; but either variant or variant and
  112. country may be omitted. For more information please refer to documentation
  113. for the
  114. <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Locale.html">Locale</a>
  115. class.</td>
  116. <td align="center" valign="top">No</td>
  117. </tr>
  118. </table>
  119. <h3>Examples</h3>
  120. <pre>
  121. &lt;tstamp/&gt;
  122. </pre>
  123. <p>
  124. sets the standard <code>DSTAMP</code>, <code>TSTAMP</code>,
  125. and <code>TODAY</code> properties according to the default formats.</p>
  126. <pre>
  127. &lt;tstamp&gt;
  128. &lt;format property=&quot;TODAY_GB&quot; pattern=&quot;d-MMMM-yyyy&quot; locale=&quot;en,GB&quot;/&gt;
  129. &lt;/tstamp&gt;
  130. </pre>
  131. <p>
  132. sets the standard properties as well as the property
  133. <code>TODAY_UK</code> with the date/time pattern &quot;d-MMMM-yyyy&quot;
  134. using English locale (eg. 21-May-2001).</p>
  135. <pre>
  136. &lt;tstamp&gt;
  137. &lt;format property=&quot;touch.time&quot; pattern=&quot;MM/dd/yyyy hh:mm aa&quot;
  138. offset=&quot;-5&quot; unit=&quot;hour&quot;/&gt;
  139. &lt;/tstamp&gt;
  140. </pre>
  141. <p>
  142. Creates a timestamp, in the property touch.time, 5 hours before the current time. The format in this example
  143. is suitable for use with the <code>&lt;touch&gt;</code> task. The standard properties are set also.</p>
  144. <pre>
  145. &lt;tstamp prefix="start"/&gt;
  146. </pre>
  147. <p>
  148. Sets three properties with the standard formats, prefixed with "start.":
  149. <code>start.DSTAMP</code>, <code>start.TSTAMP</code>, and <code>start.TODAY</code>.</p>
  150. </body>
  151. </html>