Java Mailing List Archive

http://www.ant-tasks.com/

Apache Ant Archive

» Ant Users List
» Ant Developers List
<date > selector

<date > selector

2003-02-07       - By Ciramella, Edward

I want to write a target to delete all items that are after a particular
date.

Before I roll this out, I wanted to test my functionality in the following
manner:
-create a file
-sleep 2 min
-create a file
-sleep 2 min
-create a file
-sleep 2 min
-create a file

-take a timestamp
-delete all files older than timestamp -2 min

every time I run this it deletes all my files vs just the ones that are
currenttime-2min old.

What am I missing?

<target name="build">
    <touch file="myfile-1.txt"/>
<sleep minutes="2"/>
    <touch file="myfile-2.txt"/>
<sleep minutes="2"/>
    <touch file="myfile-3.txt"/>
<sleep minutes="2"/>
    <touch file="myfile-4.txt"/>
<tstamp>
    <format property="bld.date" pattern="MM/DD/yyyy hh:mm a" locale="en"
offset="-2 unit="minute"/>
</tstamp>

<echo message="${bld.date}"/>
  <delete>
    <fileset dir="." includes="**/*.txt">
  <date datetime="${bld.date}" when="before"/>
    </fileset>
 </delete>

</target>



©2008 ant-tasks.com - Jax Systems, LLC, U.S.A.