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

1 thought on “Timestamp using ANT

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.