Tag Archives: Timestamp using ANT

Timestamp using ANT

Hi All,

In this article I will show how to create a Timestamp using ANT script, Timestamps are very helpful when we are creating daily code review reports, war/ear files, as we can simply append the timestamp with file name which gives us the ease of identifying the file creation date & time.

When we execute <tstamp/>, it generates the local ANT macros ${TSTAMP} and ${DSTAMP}. These are the time and date as numeric strings. They can then be used to dynamically generate timestamp strings.

The below is an example of using time stamp on Jar file creation:

<jar jarfile=”${jar}-${DSTAMP}${TSTAMP}.jar” compress=”true”> …. </jar>

TSTAMP – sets the DSTAMP, TSTAMP, and TODAY properties in the current project.

[NOTE]  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”.

Hope this helps.

R Vashi