ANT application (3)

xiaoxiao2021-03-06  107

4.4 Timestamp Use the current time and date in the generated environment to mark the output of a generated task in some way to record when it is generated, which is often desirable. This may involve editing a file to insert a string to specify the date and time, or merge this information into the file name of the JAR or ZIP file. This needs is solved by simple but very useful TSTAMP tasks. This task is usually called at the beginning of a certain generation process, such as in an init target. This task does not require attributes, and only is enough in many cases. TSTAMP does not produce any output; in contrast, it sets the ANT attribute based on the current system time and date. Below is some properties of TSTAMP settings, an example of each attribute, and the values ​​of these attributes can be set: Attribute Description DSTAMP is set to the current date, the default format is set to the current time, the default format is HHMM 1603Today is set to the current date, with a complete month, December 17, 2003, for example, in the previous section, we created a JAR file as follows: After calling the TSTAMP task, we can name the JAR file according to the date, as shown below: therefore, if this task is in December 2003 On the 17th, the JAR file will be named package-20031217.jar. You can also configure TSTAMP tasks to set different properties, apply a time offset before or after a current time, or format the string in different ways. All of this is done using a nested format element, as shown below: The above list sets the OFFSET_TIME attribute to the number of hours, minutes, and seconds of the number after 10 minutes. The characters used to define the format string are the same as those defined by the Java.Text.SIMPLEDATEFORMAT class.

转载请注明原文地址:https://www.9cbs.com/read-98913.html

New Post(0)