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 5.5 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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> properties in the
  25. current project. By default, the <code>DSTAMP</code> property is in the
  26. format <q>yyyyMMdd</q>, <code>TSTAMP</code> is in the format <q>hhmm</q>, and <code>TODAY</code> is
  27. in the format <q>MMMM dd yyyy</q>. Use the nested <code>&lt;format&gt;</code> element to specify a
  28. different format.</p>
  29. <p>These properties can be used in the build file, for instance, to create timestamped filenames, or
  30. used to replace placeholder tags inside documents to indicate, for example, the release date. The
  31. best place for this task is probably in an initialization target.</p>
  32. <p><em>Since Ant 1.10.2</em> the magic property <code>ant.tstamp.now</code> can be used to specify a
  33. fixed date value in order to create reproducible builds. Its value must be a number and is
  34. interpreted as seconds since the epoch (midnight 1970-01-01). With <code>ant.tstamp.now.iso</code>
  35. you could also specify that value in ISO-8601 format (<code>1972-04-17T08:07:00Z</code>). If you
  36. specify a value in an invalid format an INFO message will be logged and the value will be
  37. ignored.</p>
  38. <h3>Parameters</h3>
  39. <table class="attr">
  40. <tr>
  41. <th>Attribute</th>
  42. <th>Description</th>
  43. <th>Required</th>
  44. </tr>
  45. <tr>
  46. <td>prefix</td>
  47. <td>Prefix used for all properties set.</td>
  48. <td>No; default is no prefix</td>
  49. </tr>
  50. </table>
  51. <h3>Nested Elements</h3>
  52. <p>The <code>Tstamp</code> task supports a <code>&lt;format&gt;</code> nested element that allows a
  53. property to be set to the current date and time in a given format. The date/time patterns are as
  54. defined in the
  55. Java <a href="https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html">SimpleDateFormat</a>
  56. class. The format element also allows offsets to be applied to the time to generate different time
  57. values.</p>
  58. <table class="attr">
  59. <tr>
  60. <th>Attribute</th>
  61. <th>Description</th>
  62. <th>Required</th>
  63. </tr>
  64. <tr>
  65. <td>property</td>
  66. <td>The property to receive the date/time string in the given pattern.</td>
  67. <td>Yes</td>
  68. </tr>
  69. <tr>
  70. <td>pattern</td>
  71. <td>The date/time pattern to be used. The values are as defined by the Java SimpleDateFormat
  72. class.</td>
  73. <td>Yes</td>
  74. </tr>
  75. <tr>
  76. <td>timezone</td>
  77. <td>The timezone to use for displaying time. The values are as defined by the
  78. Java <a href="https://docs.oracle.com/javase/8/docs/api/java/util/TimeZone.html">TimeZone</a>
  79. class.</td>
  80. <td>No</td>
  81. </tr>
  82. <tr>
  83. <td>offset</td>
  84. <td>The numeric offset to the current time</td>
  85. <td>No</td>
  86. </tr>
  87. <tr>
  88. <td>unit</td>
  89. <td>The unit of the offset to be applied to the current time. Valid values are
  90. <ul>
  91. <li><q>millisecond</q></li>
  92. <li><q>second</q></li>
  93. <li><q>minute</q></li>
  94. <li><q>hour</q></li>
  95. <li><q>day</q></li>
  96. <li><q>week</q></li>
  97. <li><q>month</q></li>
  98. <li><q>year</q></li>
  99. </ul>
  100. </td>
  101. <td>No</td>
  102. </tr>
  103. <tr>
  104. <td>locale</td>
  105. <td>The locale used to create date/time string. The general form is <q>language[, country[,
  106. variant]]</q> (either <q>variant</q> or both <q>variant</q> and <q>country</q> may be
  107. omitted). For more information please refer to documentation for
  108. the <a href="https://docs.oracle.com/javase/8/docs/api/java/util/Locale.html">Locale</a>
  109. class.</td>
  110. <td>No</td>
  111. </tr>
  112. </table>
  113. <h3>Examples</h3>
  114. <pre>&lt;tstamp/&gt;</pre>
  115. <p>sets the standard <code>DSTAMP</code>, <code>TSTAMP</code>, and <code>TODAY</code> properties
  116. according to the default formats.</p>
  117. <pre>
  118. &lt;tstamp&gt;
  119. &lt;format property=&quot;TODAY_GB&quot; pattern=&quot;d-MMMM-yyyy&quot; locale=&quot;en,GB&quot;/&gt;
  120. &lt;/tstamp&gt;</pre>
  121. <p>sets the standard properties as well as the property <code>TODAY_UK</code> with the date/time
  122. pattern <q>d-MMMM-yyyy</q> using English locale (eg. 21-May-2001).</p>
  123. <pre>
  124. &lt;tstamp&gt;
  125. &lt;format property=&quot;touch.time&quot; pattern=&quot;MM/dd/yyyy hh:mm aa&quot;
  126. offset=&quot;-5&quot; unit=&quot;hour&quot;/&gt;
  127. &lt;/tstamp&gt;</pre>
  128. <p>Creates a timestamp, in the property <code>touch.time</code>, 5 hours before the current
  129. time. The format in this example is suitable for use with the <code>&lt;touch&gt;</code> task. The
  130. standard properties are set also.</p>
  131. <pre>&lt;tstamp prefix="start"/&gt;</pre>
  132. <p>Sets three properties with the standard formats, prefixed
  133. with <q>start.</q>: <code>start.DSTAMP</code>, <code>start.TSTAMP</code>,
  134. and <code>start.TODAY</code>.</p>
  135. </body>
  136. </html>