Here's an example solution:
<scriptdef name="filedate" language="javascript">
<attribute name="file"/>
<attribute name="property"/>
<![CDATA[
var file_name = attributes.get( "file" );
var property_to_set = attributes.get( "property" );
var file = new java.io.File( file_name );
var file_date = file.lastModified();
project.setProperty( property_to_set, file_date );
]]>
</scriptdef>
<last id="last.dir">
<sort>
<fileset dir="folder" includes="*" />
<date />
</sort>
</last>
<filedate file="${ant.refid:last.dir}" property="file.ts" />
<touch file="concat.file" millis="${file.ts}" />
The scriptdef is derived from this answer by David W. and simplified as we don't need to format the date-time, we can just use the "epoch milliseconds" that Java File lastModified()
provides and the Ant touch task expects.