Creating a timestamp with ANT in FDT

by Sidney de Koning

Lately i’ve been doing a lot of automation of my work flow, mainly because i’m lazy ;) All these repetitive tasks are such a waste of time to do every single time, over and over again. Thankfully there is a way to smooth out this process!

So my solution was this: take some time and research all the tasks I use on a daily basis and see if I can automate the with ANT, straight from FDT.

For this specific project i’m doing I need to do this:

  1. Zip files with a specific file name (project_name_dateformat_in_dd_MM_yyyy_HH_mm)
  2. Copy files to a network share
  3. Upload zip file to FTP
  4. Mail our support desk so they deploy the files I copied to the network share.

This is all possible with ANT with one mouse click :) So this saves me shitloads of time everytime. I need to do about 10 to 15 small deploys a day, so that saves me 50 to 75 minutes a day to do my own stuff!
So over the coming days I will post seperate ANT targets plus a generic project file you can use in your projects! (And all will be easily configurable with a properties file)

Lets start off real basic by creating a timestamp target:

A timestamp in ANT is easily created with the task. If you want custom formatting of the time/date string you can use the guidelines provided by this document.

You can set custom formatting like so:

	
	
		
			
			
			
			
		
		
		
		
		
	



And now you can use current.date.time as a property like ${current.date.time} with an ANT target. What I have noticed is that is you don’t use a “.properties” file you have to call this target every time you want to use it. It does not stay in memory. With an properties file it does.

This is what the output looks like:

ANT Timestamp log

Here is the XML file with the project.
Happy timesaving :)