Ant - Using timestamp examples

By xngo on June 29, 2019

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="create_directory_with_timestamp" name="Show how to use tstamp.">
 
  <target name="create_directory_with_timestamp">
 
    <!-- Declare the timestamp format of DAY_TIME_NOW -->
    <tstamp><format property="DAY_TIME_NOW" pattern="yyyy-MM-dd_HH.mm.ss" /></tstamp>
 
    <!-- Using DAY_TIME_NOW to create a directory called DAY_TIME_NOW -->
    <mkdir dir="${DAY_TIME_NOW}"/>
 
  </target>
 
</project>

About the author

Xuan Ngo is the founder of OpenWritings.net. He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.